Closed Bug 174617 Opened 23 years ago Closed 23 years ago

Name attribute not recognized by getElementById() method

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

VERIFIED WONTFIX

People

(Reporter: lupufr, Assigned: jst)

References

()

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1) Gecko/20020826 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.1) Gecko/20020826 Trying to get a reference with getElementById() method to an HTML form control which doesn't an id attribute fails. Name attribute is not recognized by getElementById() method in Mozilla (it is in IE browsers). Note that id can't be used instead of name to create key/value pairs when submitting the form. Reproducible: Always Steps to Reproduce: 1. Create a form with a text input with only a name attribute 2. Try to get its value with getElementById() method Actual Results: Mozilla JavaScript Console gives you : Error: myText has no properties Source File: http://1ppl.free.fr/mozilla/mozilla01/ Line: 9 To Mozilla, control is not "named" until you add an id attribute to it. Expected Results: Should launch an alert with the text input value. Please find an HTML test case at the following url : http://1ppl.free.fr/mozilla/mozilla01/
Attached file HTML Test Case
IE is broken, getElementById() does exactly what the name says, anything else is just wrong. WONTFIX.
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → WONTFIX
Ok - Another browser wars thing to live with... It's just a useful feature even it's not part of the "standard". Thx.
Verified. If you want names, use document.getElementsByNames() which is part of the DOM HTML spec. http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259
Status: RESOLVED → VERIFIED
*** Bug 269420 has been marked as a duplicate of this bug. ***
*** Bug 306784 has been marked as a duplicate of this bug. ***
many people have both name and id on the same element
Component: DOM: HTML → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: