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.
*** Bug 20029 has been marked as a duplicate of this bug. ***
Reassigning to Eric.
QA Contact update.
19 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
Status: ASSIGNED → RESOLVED
Last Resolved: 19 years ago
Resolution: --- → WORKSFORME
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.value is: value1 Marking this WORKSFORME. Thanks!
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.