Closed Bug 266341 Opened 21 years ago Closed 21 years ago

input type="image" elements don't appear in form.elements

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: howard, Unassigned)

References

Details

User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.3) Gecko/20040914 Firefox/0.10.1 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.3) Gecko/20040914 Firefox/0.10.1 A simple form with 2 controls: one text, one image, should appear in Javascript: form.elements.length == 2 But image controls don't appear in the elements collection. Why not? Reproducible: Always Steps to Reproduce: Display this file in a browser: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head><title></title><script type="text/javascript"> function ecount() { alert("length="+document.getElementById('formid').elements.length); } </script></head><body onload="ecount()"> <form id="formid" action=""><p><input type="text" name="textinput"> <input type="image" name="imginput" src="image.png"></p></form> </body></html> Actual Results: An alert box saying "length=1" Expected Results: An alert box saying "length=2" For what it's worth, all other browsers I've checked (Opera/Win, IE/Win, Safari/OSX) exhibit the same behavior. But the spec (at http://www.w3.org/TR/DOM-Level-2-HTML/html.html) says: elements of type HTMLCollection, readonly Returns a collection of all form control elements in the form. There's no mention of excluding certain types of controls from the collection. Neither is there any mention of discrimination against image controls in the HTML spec: http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#edef-INPUT
> For what it's worth, all other browsers I've checked (Opera/Win, > IE/Win, Safari/OSX) exhibit the same behavior That's not a concidence. The de-facto standard is that image inputs don't appear in form.elements, and it's implemented interoperably by all browsers. Doing anything else would break far too many pages. See similar issue in bug 88846
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → WONTFIX
Component: DOM: HTML → DOM: Core & HTML
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.