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="JavaS cript" type="text/javascript">
function CheckAll(field)
{
for (loop=0; loop < field.length; loop++)
{
field[loop].checked = true;
}
}
function UnCheckAll(fiel d)
{
for (loop=0; loop < field.length; loop++)
{
field[loop].checked = false;
}
}
</script>
<?php
echo '<form name="TestSelec t_Form" method="GET" action="TestLis t.php"
enctype="text/plain" style="margin:0 px">
<input type="radio" name="SelectOrN ot" value="Select_A ll"
onClick="CheckA ll(document.Tes tSelect_Form.Se lectModule)"
style="position :absolute;left: 290px;top:140px ;z-index:6">
<input type="radio" name="SelectOrN ot" value="Uncheck_ All"
onClick="UnChec kAll(document.T estSelect_Form. SelectModule)" checked
style="position :absolute;left: 400px;top:140px ;z-index:7">';
$file_name = "CONF/testselect.txt" ;
$fp_TstSlct = fopen("$file_na me", "r") or die("Some error occurred
while opening 'testSelect.txt ");
$TopPos = 170;
while(!feof($fp _TstSlct))
{
$TstSlct_data = fgets($fp_TstSl ct);
preg_match_all( "/([#]*)(.*)\s(\d+)\s *[;#]*(.*)/", $TstSlct_data,
$match, PREG_PATTERN_OR DER);
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="SelectMod ule[]" value=' .
$match[2][0] . ' checked="checke d" style="position :absolute;left:
90px;top:' . $TopPos . 'px">';
} else {
echo '<input type="checkbox" name="SelectMod ule[]" 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"><d iv
class="wpmd">';
echo '<div><font face="Arial">' . $match[2][0] . '</font></div>';
echo '</div></div>';
$TopPos = $TopPos + 25;
}
}
fclose($fp_TstS lct);
echo '<input name="Configure TestList" 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">Se lect 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">Un check All</font></div>
</div></div>';
?>
Please someone suggest the solution as I'm totally stuck.
Thanks a lot in advance.