I'm creating a dynamic table of data with a check box on the leftside. What I want to do is be able to select all or unselect all with a master check box. I can get this to work with javascript if the checkbox name is static eg. record instead of and array record[].
Does anyone have any suggestions?
Javascript:
Code: Select all
<SCRIPT LANGUAGE="JavaScript">
<!--
<!-- Begin
function Check(chk)
{
if(document.myform.Check_ctr.checked==true){
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}else{
for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}
}
// End -->
</script>Code: Select all
...
<?php session_start();
if(isset($_SESSION['myusername'])){?>
<form name="myform" method="post" action="med.php" >
<th><input type="checkbox" name="Check_ctr" value="yes" onClick="Check(document.myform.record)"></th>
<?php } ?>
...
echo("<td><input type=\"checkbox\" name=\"record\" value=" . $row['ContactID'] . "></td>");
...Below passes all the data, but no master select option...
Code: Select all
...
<?php session_start();
if(isset($_SESSION['myusername'])){?>
<form name="myform" method="post" action="med.php" >
<th><input type="checkbox" name="Check_ctr" value="yes" onClick="Check(document.myform.record[])"></th>
<?php } ?>
...
echo("<td><input type=\"checkbox\" name=\"record[]\" value=" . $row['ContactID'] . "></td>");
...Thanks in advance.