nimzie Posted January 10, 2008 Share Posted January 10, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/85359-checking-all-checkboxes-in-a-table-within-a-form/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.