Closed
Bug 20028
Opened 25 years ago
Closed 25 years ago
not possible to access SELECT element's "options" array from a DOMElement.
Categories
(Core :: Layout: Form Controls, defect, P3)
Tracking
()
VERIFIED
WORKSFORME
M14
People
(Reporter: bugs, Assigned: pollmann)
References
Details
Attachments
(1 file)
613 bytes,
text/html
|
Details |
What happens: I have a select element with an ID attribute: <SELECT ID="foo"> <OPTION VALUE="value1">Option 1</OPTION> <OPTION VALUE="value2">Option 2</OPTION> </SELECT> I can only get this element easily via selectElement = document.getElementById("foo"); However when I do this I cannot get the "options" array property of the select element as I would normally do: index = selectElement.options.selectedIndex; value = selectElement.options[index].value; returns an error "selectElement.options has no properties" However if I create a form and give the element a name, I can: selectElement = document.form1.select1; .. as above .. Since in both cases selectElement refers to the same object, I would have thought that I would be able to access identical properties.
Updated•25 years ago
|
Assignee: karnaze → pollmann
Comment 2•25 years ago
|
||
Reassigning to Eric.
Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Target Milestone: M14
Assignee | ||
Comment 4•25 years ago
|
||
Don't know why this might be. I'm taking a look at this. But until then please also note: According to the spec, "selectedIndex" is a property of the select element, and not a property of the options array. Your example should read: selectElement = document.getElementById("foo"); index = selectElement.selectedIndex; value = selectElement.options[index].value; This is, however, a backwards compatability issue and is being addressed. See bug 12513
Assignee | ||
Comment 5•25 years ago
|
||
Assignee | ||
Updated•25 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → WORKSFORME
Assignee | ||
Comment 6•25 years ago
|
||
I am unable to reproduce the problem in today's build. See attached test case. On today's Linux build I got this: select is: [object HTMLSelectElement] select.options is: [object HTMLCollection] select.selectedIndex is: 0 select.options[0].value is: value1 Marking this WORKSFORME. Thanks!
Comment 7•24 years ago
|
||
tested on win95 3-31-00 build works marking verified
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•