It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

problem on select/deselect all check box

problem on select/deselect all check box

Postby bhanukaputer on Mon Nov 09, 2009 9:57 am

This is the code of JavaScript I am using for select/deselect all check box but the value of list.checked is undefined...

Code: Select all
<script type="text/javascript">
function checkIt(list)
{
   if(list.checked == false)
   {   
      for(var i = 0;i < list.length;i++)
      {
         list[i].checked = true;
      }
   }
   else
   {
      for(var i = 0;i < list.length;i++)
      {
         list[i].checked = false;
      }
   }
}
</script>


And I call this script in below form...

Code: Select all
<form action="delete.php" method="post" name="frm">
<table width="400" height="123" align="center" rules="rows">
<tr>
<th width="106"><div align="left"><input name="all" type="checkbox" id="all" onPropertyChange="checkIt(this.form.check);" />Select All
</div></th><th width="68"><div align="left">Name</div></th><th width="53"><div align="left">Age</div></th><th width="45"><div align="left">Sex</div></th><th width="104"><div align="left">Occupation</div></th>
</tr>
<?php
while($row=mysql_fetch_row($result))
{
?>
<tr>
<td><input type="checkbox" value="<?php echo $row[0];?>" name="check[]" /></td><td><?php echo $row[1];?></td><td><?php echo $row[2];?></td><td><?php echo $row[3];?></td><td><?php echo $row[4];?></td>
</tr>
<?php }?>
<tr>
<td colspan="5" align="center"><input type="submit" value="Delete" name="delete" /></td>
</tr>
</table>
</form>
bhanukaputer
 
Posts: 1
Joined: Mon Nov 09, 2009 9:13 am

Who is online

Users browsing this forum: No registered users and 4 guests