Jump to content

Checking all checkboxes .. in a table within a form?


nimzie

Recommended Posts

I found this script:

<script language="JavaScript"> 

function Checkall(form){ 
  for (var i = 1; i < form.elements.length; i++){    
    eval("form.elements[" + i + "].checked = form.elements[0].checked");  
  } 
}
</script>

 

Trying to go through this table and check / uncheck all the checkboxes as anyone would expect a check all checkbox to do...

 

I build the table with a loop/php from a query, so there can be many records.

 

Right now, if I check 3 checkboxes in the table, then click check all, they all uncheck.

The "check all" control isn't getting checked when I click it and if I click the main one without anything checked, it appears as if nothing happens. No checkboxes in the table do anything.

 

Please advise :)

Thanks,

 

Adam

 

<form name="myForm" action="<?php echo $_SERVER['PHP_SELF']; ?>"  method="post">
    <input type="checkbox" onClick="Checkall('myForm');" />Check all Records<br />
    <table>
         <tr>
           <td>Process Order</td>
           <td>OrderID</td>
         </tr>
         <tr>
           <td> <input type="checkbox" name="checkbox" ><br /> </td>
           <td>orderid</td>
         </tr>
    </table>
</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.