I have dynamically defined the following checkboxes using PHP:
<input type="checkbox" name="accommodation_dates[]" value=http://www.webdeveloper.com/forum/archive/index.php/"13">
<input type="checkbox" name="accommodation_dates[]" value="14">
<input type="checkbox" name="accommodation_dates[]" value="15">
<input type="checkbox" name="accommodation_dates[]" value="16">
<input type="checkbox" name="accommodation_dates[]" value="17">
When the form is submitted, I have no problem dealing with the results.
My problem is that I want to determine how many of these checkboxes are checked in a Javascript function.
I refer to the checkboxes as follows:
for(i=0;i<5;i++) {
if (document.reg_form.accommodation_dates.checked) {
... do whatever ...
}
}
This works if the checkboxes are defined without the [], but my PHP stuff on submit won't work unless the [] are there.
Any suggestions would be appreciated.
<input type="checkbox" name="accommodation_dates[]" value=http://www.webdeveloper.com/forum/archive/index.php/"13">
<input type="checkbox" name="accommodation_dates[]" value="14">
<input type="checkbox" name="accommodation_dates[]" value="15">
<input type="checkbox" name="accommodation_dates[]" value="16">
<input type="checkbox" name="accommodation_dates[]" value="17">
When the form is submitted, I have no problem dealing with the results.
My problem is that I want to determine how many of these checkboxes are checked in a Javascript function.
I refer to the checkboxes as follows:
for(i=0;i<5;i++) {
if (document.reg_form.accommodation_dates.checked) {
... do whatever ...
}
}
This works if the checkboxes are defined without the [], but my PHP stuff on submit won't work unless the [] are there.
Any suggestions would be appreciated.