In order to have the form variables processed into an array automatically by PHP, you have to put put a '[]' after the name parameter in any form element that will accept multiple selections.
ex.
<input type="checkbox" name="choice[]" value="choice 1">
<input type="checkbox" name="choice[]" value="choice 2">
assuming the user checks both boxes, after you submit the form unsing a PHP script as the action PHP will generate the following array:
choice[0] = 'choice 1'
choice[1] = 'choice 2'
The problem I am having is that I have to use the form data for multiple purposes and one includes using JavaScript to open a window using certain values that are checked.
It crashes on the following statement:
if (document.my_favorites.choice[].checked) {
count++
}
since my variable name, 'choice[]', also happens to be the same syntax as a JavaScript array, Javascript is looking for an array and it can't find it. Thus, I have an invalid object.
Hope this makes sense, I'm starting to confuse myself now...🙂
Thanks,
Rich