P
PhpCool
Hi, since sometime I'm stuck in a problem where I want to check or
uncheck all the checkboxes. If I'm choosing name for the checkbox
array as 'chkbx_ary' then I'm able to check/uncheck all the checkboxes
(code pasted below). But if name of the checkbox array is
'chkbx_ary[]' then it's failing. I want the name to be 'chkbx_ary[]'
because I want to access this array at server side.
Though one may not require to see php part but I'm still pasting the
code.
<script language="JavaScript" type="text/javascript">
function CheckAll(field)
{
for (loop=0; loop < field.length; loop++)
{
field[loop].checked = true;
}
}
function UnCheckAll(field)
{
for (loop=0; loop < field.length; loop++)
{
field[loop].checked = false;
}
}
</script>
<?php
echo '<form name="TestSelect_Form" method="GET" action="TestList.php"
enctype="text/plain" style="margin:0px">
<input type="radio" name="SelectOrNot" value="Select_All"
onClick="CheckAll(document.TestSelect_Form.SelectModule)"
style="position:absolute;left:290px;top:140px;z-index:6">
<input type="radio" name="SelectOrNot" value="Uncheck_All"
onClick="UnCheckAll(document.TestSelect_Form.SelectModule)" checked
style="position:absolute;left:400px;top:140px;z-index:7">';
$file_name = "CONF/testselect.txt";
$fp_TstSlct = fopen("$file_name", "r") or die("Some error occurred
while opening 'testSelect.txt");
$TopPos = 170;
while(!feof($fp_TstSlct))
{
$TstSlct_data = fgets($fp_TstSlct);
preg_match_all("/([#]*)(.*)\s(\d+)\s*[;#]*(.*)/", $TstSlct_data,
$match, PREG_PATTERN_ORDER);
if ( $match[2][0] != NULL ) { //Checking whether module is present
or not. May be only comments have been put. For. e.g.
###################DSL HOME#########
if ( $match[1][0] == NULL ) { //Checking if line is starting with
'#' or not
echo '<input type="checkbox" name="SelectModule[]" value=' .
$match[2][0] . ' checked="checked" style="position:absolute;left:
90px;top:' . $TopPos . 'px">';
} else {
echo '<input type="checkbox" name="SelectModule[]" value=' .
$match[2][0] . ' style="position:absolute;left:90px;top:' . $TopPos .
'px">';
}
echo '<div id="text3" style="position:absolute; overflow:hidden;
left:130px; top:' . $TopPos . 'px; width:79px; height:16px"><div
class="wpmd">';
echo '<div><font face="Arial">' . $match[2][0] . '</font></div>';
echo '</div></div>';
$TopPos = $TopPos + 25;
}
}
fclose($fp_TstSlct);
echo '<input name="ConfigureTestList" type="submit" value="Next"
style="position:absolute;left:326px;top:403px;z-index:16">
</form>
<div id="text1" style="position:absolute; overflow:hidden; left:
265px; top:118px; width:69px; height:18px; z-index:9"><div
class="wpmd">
<div><font class="ws12" face="Arial">Select All</font></div>
</div></div>
<div id="text2" style="position:absolute; overflow:hidden; left:
371px; top:118px; width:85px; height:18px; z-index:10"><div
class="wpmd">
<div><font class="ws12" face="Arial">Uncheck All</font></div>
</div></div>';
?>
Please someone suggest the solution as I'm totally stuck.
Thanks a lot in advance.
uncheck all the checkboxes. If I'm choosing name for the checkbox
array as 'chkbx_ary' then I'm able to check/uncheck all the checkboxes
(code pasted below). But if name of the checkbox array is
'chkbx_ary[]' then it's failing. I want the name to be 'chkbx_ary[]'
because I want to access this array at server side.
Though one may not require to see php part but I'm still pasting the
code.
<script language="JavaScript" type="text/javascript">
function CheckAll(field)
{
for (loop=0; loop < field.length; loop++)
{
field[loop].checked = true;
}
}
function UnCheckAll(field)
{
for (loop=0; loop < field.length; loop++)
{
field[loop].checked = false;
}
}
</script>
<?php
echo '<form name="TestSelect_Form" method="GET" action="TestList.php"
enctype="text/plain" style="margin:0px">
<input type="radio" name="SelectOrNot" value="Select_All"
onClick="CheckAll(document.TestSelect_Form.SelectModule)"
style="position:absolute;left:290px;top:140px;z-index:6">
<input type="radio" name="SelectOrNot" value="Uncheck_All"
onClick="UnCheckAll(document.TestSelect_Form.SelectModule)" checked
style="position:absolute;left:400px;top:140px;z-index:7">';
$file_name = "CONF/testselect.txt";
$fp_TstSlct = fopen("$file_name", "r") or die("Some error occurred
while opening 'testSelect.txt");
$TopPos = 170;
while(!feof($fp_TstSlct))
{
$TstSlct_data = fgets($fp_TstSlct);
preg_match_all("/([#]*)(.*)\s(\d+)\s*[;#]*(.*)/", $TstSlct_data,
$match, PREG_PATTERN_ORDER);
if ( $match[2][0] != NULL ) { //Checking whether module is present
or not. May be only comments have been put. For. e.g.
###################DSL HOME#########
if ( $match[1][0] == NULL ) { //Checking if line is starting with
'#' or not
echo '<input type="checkbox" name="SelectModule[]" value=' .
$match[2][0] . ' checked="checked" style="position:absolute;left:
90px;top:' . $TopPos . 'px">';
} else {
echo '<input type="checkbox" name="SelectModule[]" value=' .
$match[2][0] . ' style="position:absolute;left:90px;top:' . $TopPos .
'px">';
}
echo '<div id="text3" style="position:absolute; overflow:hidden;
left:130px; top:' . $TopPos . 'px; width:79px; height:16px"><div
class="wpmd">';
echo '<div><font face="Arial">' . $match[2][0] . '</font></div>';
echo '</div></div>';
$TopPos = $TopPos + 25;
}
}
fclose($fp_TstSlct);
echo '<input name="ConfigureTestList" type="submit" value="Next"
style="position:absolute;left:326px;top:403px;z-index:16">
</form>
<div id="text1" style="position:absolute; overflow:hidden; left:
265px; top:118px; width:69px; height:18px; z-index:9"><div
class="wpmd">
<div><font class="ws12" face="Arial">Select All</font></div>
</div></div>
<div id="text2" style="position:absolute; overflow:hidden; left:
371px; top:118px; width:85px; height:18px; z-index:10"><div
class="wpmd">
<div><font class="ws12" face="Arial">Uncheck All</font></div>
</div></div>';
?>
Please someone suggest the solution as I'm totally stuck.
Thanks a lot in advance.