Brendan Nolan
05-12-2003, 02:21 AM
I am writing a PHP application which has a form in it.
The form has a list of results and a checkbox next to each of them.
I found out that if I named the checkbox "checkbox[]" instead of "checkbox" it will store the checked rows in an array in PHP, otherwise it will just overwrite the previous values and store only the last one.
But I want to have a "Check / Uncheck All" button, and I can use
document.forms.some_form.checkbox.checked=true;
and if I have a bunch of checkboxes all named "checkbox" i can use
document.forms.some_form.checkbox[1].checked=true;
document.forms.some_form.checkbox[2].checked=true;
document.forms.some_form.checkbox[3].checked=true;
etc.
But how do I do it if I name my checkbox "checkbox[]" so that I get that nice array in PHP?
I have tried things like
document.forms.some_form.checkbox[][1].checked=true;
and
document.forms.some_form.checkbox\[\][1].checked=true;
and even
document.forms.some_form.checkbox%5B%5D[1].checked=true;
(••• I DID name the checkbox "checkbox%5B%5D" in that one!)
and none of them work!
Please help :)
The form has a list of results and a checkbox next to each of them.
I found out that if I named the checkbox "checkbox[]" instead of "checkbox" it will store the checked rows in an array in PHP, otherwise it will just overwrite the previous values and store only the last one.
But I want to have a "Check / Uncheck All" button, and I can use
document.forms.some_form.checkbox.checked=true;
and if I have a bunch of checkboxes all named "checkbox" i can use
document.forms.some_form.checkbox[1].checked=true;
document.forms.some_form.checkbox[2].checked=true;
document.forms.some_form.checkbox[3].checked=true;
etc.
But how do I do it if I name my checkbox "checkbox[]" so that I get that nice array in PHP?
I have tried things like
document.forms.some_form.checkbox[][1].checked=true;
and
document.forms.some_form.checkbox\[\][1].checked=true;
and even
document.forms.some_form.checkbox%5B%5D[1].checked=true;
(••• I DID name the checkbox "checkbox%5B%5D" in that one!)
and none of them work!
Please help :)