There are 2 preferred methods instead of this syntax. The first assumes elements have an id attribute assigned:
Code:
<input type="text" [!]id="blah"[/!] value="whatever" />
can be accessed via:
document.[!]getElementById([/!]"blah"[!])[/!].value;
If you do not have id attributes assigned to the elements and are using names instead, you can use the forms and elements collections (this most closely resembles what you are doing above.
Code:
<form [!]id="theForm"[/!]>
<input type="text" [!]name="blah"[/!] value="whatever" />
</form>
can be accessed via:
document.[!]forms[[/!]"theForm"[!]].elements[[/!]"blah"[!]][/!].value;
Now, with respect to your specific question, since we are using the forms and elements collections - they receive a string to determine which element in the collection you are trying to retrieve.
It's a lot more typing, but who cares? It's a lot less prone to fail, and you won't get any arguments from the firefox error console. I have highlighted in red the derived value used in the outside elements collection:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.