Arrays and checkboxes
OK, I have been working on this for the last couple days and have made a lot of headway, but am still stuck on a spot. I have a group of checkboxes on my form that allow the user to select which items apply. I want to verify that at least one checkbox in each group has been selected before allowing them to continue. PHP requires the naming of the arrays to include the  but jsp (for verification) doesn't like it. I read about and used the .elements method to overcome part of that problem so my for loop is now executing for the number of items in my group:
for (var i=0; i<document.form1.elements['dining_out1'].length; i++)
however my if statement won't execute:
even if I have checked ALL checkboxes. I have tried all the different methods I can think of to test for a checked value on each item in the array, but I can't quite figure out what I am missing.
Any help will be greatly appreciated.
P.S. I had posted this to the Java and JSP forum and then realized it should actually be here so I am reposting it, and if possible I will now go delete my other thread. Sorry for the crosspost... been a longtime lurker, just now feel like I am getting into the code deep enough to ask some decent questions!
Tried that and it didn't work (but as a disclaimer I tried using Firefox and not IE which I have seen handle this whole situation completely differently. I ended up finding an answer in another forum post (I know I should have looked deeper before posting, my bad).
Here is the solution that got me working:
var dining_array = document.getElementsByName('dining_out1');
for (var i=0; i<dining_array.length; i++)
test_dining = 1;
alert(dining_array[i].value + " was checked")
The getElementsByName allowed me to work with the array again and seems to have passed the proper values over (I don't need the actual values, just to verify that at least one checkbox was checked in each group) but it is still nice to see that I could use this for further data handling if necessary.