thepip3r
09-22-2005, 04:34 PM
I've got a form where it's a bunch of checkboxes, each name of the checkbox is "bullets[]" so when the form is submitted, all of the selected checkboxes are in the $_POST['bullets'] array. My problem is that the way I have it set up in my loop, the name "bullets[]" makes my SelectAll and SelectNone Javascript functions not work any longer. JS error: "'length' is null or not an object.' Has anyone else run into this?
Javascript in page head:
<script>
function checkAll(field) {
for (i = 0; i < field.length; i++)
field[i].checked = true;
}
function uncheckAll(field) {
for (i = 0; i < field.length; i++)
field[i].checked = false;
}
</script>
PHP/HMTL Loop for Form Checkboxes and JS Func Buttons:
<input type=button name=\"CheckAll\" value=\"Check All\" onClick=\"checkAll(document.refineForm.bullets)\">
<input type=button name=\"UnCheckAll\" value=\"Uncheck All\" onClick=\"uncheckAll(document.refineForm.bullets)\">
<td rowspan=4 valign=\"top\"><input class=\"norm\" type=\"checkbox\" name=\"bullets[]\" value=\"$jobID\" checked></td>
Javascript in page head:
<script>
function checkAll(field) {
for (i = 0; i < field.length; i++)
field[i].checked = true;
}
function uncheckAll(field) {
for (i = 0; i < field.length; i++)
field[i].checked = false;
}
</script>
PHP/HMTL Loop for Form Checkboxes and JS Func Buttons:
<input type=button name=\"CheckAll\" value=\"Check All\" onClick=\"checkAll(document.refineForm.bullets)\">
<input type=button name=\"UnCheckAll\" value=\"Uncheck All\" onClick=\"uncheckAll(document.refineForm.bullets)\">
<td rowspan=4 valign=\"top\"><input class=\"norm\" type=\"checkbox\" name=\"bullets[]\" value=\"$jobID\" checked></td>