Forum Moderators: open

Message Too Old, No Replies

Have problem wit [] in script

How to "hide" [] in script

         

Marshall

8:31 am on Aug 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have a script I'm using to validate checkboxes. It forces the user to select a specific number of boxes. Each of the boxes is name="Dazs" There is a line in the script the reads:

for (i = 0; i < document.RegistrationForm.Dazs.length; i++)

The problem arises in that the form is processed using php which requires empty [] in the input name with multiple choices:

name="Dazs[]"

If I enter the [] in the script:

for (i = 0; i < document.RegistrationForm.Dazs[].length; i++)

the script returns an error. Question, how do I keep the brackets in both the "name" for the php and in the script so it knows what inputs I'm referring to?

Any help would be appreciated.
Marshall

janharders

8:39 am on Aug 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



document.RegistrationForm["Dazs[]"].length

should work iirc.

Marshall

4:33 pm on Aug 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thank you, Thank you, thank you. Worked like a charm.

Marshall :)