Forum Moderators: open

Message Too Old, No Replies

javascript & form name..

really strange

         

affter333

10:20 pm on Jul 10, 2004 (gmt 0)



<form name=f>
<input type=text name="apple[]" value=1>
</form>

<script>
a=document.f.apple[].value
</script>

///////////////////////////
this generates a javascript error in IE
because of apple[]
so how do I get around the error?
(must use "apple[]" for server cgi script)

thanks in advance..:)

Rambo Tribble

2:16 am on Jul 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably the only way around this is to use the elements[] array of the forms object. For instance, in your example you can refer to the value of the apple[] input field as document.f.elements[0].value.

Needless to say, it was probably a bad idea for the brackets to be used in the name in the first place. But, there you are.