Hi! I'm setting up a php site where I need an option to check a series of checkboxes generated with a while loop. The problem is that the name of the checkboxes has to be list[] because I'm going to implode the values on the next page. The java script won't accept [] in the checkbox name. What should I do?
Thanks!
Here's the code:
<script>
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field.checked = true;}
checkflag = "true";
return "Uncheck All"; }
else {
for (i = 0; i < field.length; i++) {
field.checked = false; }
checkflag = "false";
return "Check All"; }
}
</script>
<FORM method=post name=f1>
<INPUT type=checkbox name=list onClick="this.value=check(this.form.list);">All<br>
<INPUT type=checkbox name=list value="2">Air<br>
<INPUT type=checkbox name=list value="3">Monitoring<br>
<INPUT type=checkbox name=list value="4">Water<br>
<INPUT type=checkbox name=list value="5">Pollution Prevention<br>
</FORM>