document.getElementById() selects an element by its name.
Browser
Internet Explorer
Example
Relevant HTML code:
[HTML]<input name="test" type="text" value="test">[/HTML]
The Javascript code:
Expand|Select|Wrap|Line Numbers
- var obj = document.getElementById("test");
Solution
This is a bug which will cause problems in most, if not all, other browsers. document.getElementById() should get an element by its ID as the name suggests, not by its name. This will also cause problems in IE when you have an element with a name the same as the ID of the element you actually want to access. The wrong element will be accessed!
Be careful how you name your elements. Do not use the same name as the ID of another element.
More Bugs, Quirks and Inconsistencies