Closed Bug 88076 Opened 23 years ago Closed 23 years ago

returned Selected Index is -1

Categories

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

x86
All
defect
Not set
major

Tracking

()

VERIFIED WORKSFORME

People

(Reporter: stummala, Assigned: jst)

References

Details

Attachments

(1 file)

From Bugzilla Helper: User-Agent: Mozilla/4.77 [en] (Windows NT 5.0; U) BuildID: Linux2001-06-20-06 document.write(document.getElementsByTagName('SELECT')[0].selectedIndex); always returns -1 .. Reproducible: Always Steps to Reproduce: <HTML> <BODY> <form> <SELECT size="7"> <option>eeyore <option>pooh <option>piglet <option>tigger <option>owl <option>rabbit <option selected>elephant <option>penguin <option>#41 <option>you had time <option>out of range <option>crush <option>gypsy <option>language <option>sometimes </SELECT> <SELECT size="2"> </SELECT> </form> <SCRIPT type="text/javascript"> document.write(document.getElementsByTagName('SELECT')[0].selectedIndex); </SCRIPT> </BODY> </HTML> use the above incase u cannot load the testcase Actual Results: -1 was returned Expected Results: expected return value=6
I see this with Mozilla 2001062204 on Win2k. I added a javascript alert to body onload="alert(document.getElementsByTagName('SELECT')[0].selectedIndex)" and it returns the correct value of 6. Perhaps the collection isn't initialized or the selection isn't made until the page loads?
OS: Linux → All
See also bug 51365
*** Bug 89153 has been marked as a duplicate of this bug. ***
Guys, This bug sounds pretty important to me. There are tons of websites which rely on selectedIndex value to redirect to appropriate page. or to submit approriate selected value. Examples are like www.carpoint.com
It seems this is only a problem while the page is loading. I don't know how many sites would use the value of a select in inline script code. I'd expect it to be rare. After load, it's fine, so submits should work correctly.
Phil, need your opinion. Adding Phil Schwartau to cc list.
Similar to these bugs: bug 89425 "JavaScript select on multiple select box is malfunctioning" In certain circumstances, not possible to set this via JavaScript: document.formA.selectA[i].selected = true; Which in turn has been suggested as a duplicate of: bug 86659 "Alteration of select widget by JavaScript broken" > In Mozilla 0.9.1+ the ability for JavaScript to change the selected item in a > select form widget is broken. The referenced URL is a simplified test of this > bug which works under NS 4.7 and Moz 0.9.1 but is broken under Moz 0.9.1+ > When you click the button on the page, "Item 2" (which is form.sel.option[2]) > should become the selected option, but instead form.sel.option[0] is selected, > the default.
Is this exact construct heavily used in the web at large? Using the testcase, it does show that the answer is only wrong while the page is loading. That seems to limit the exposure significantly (and isn't terribly different from every other client with flaky behavior before the page is loaded - 4.x was horrible in this regard.) My impression is that Johnny has his hands full already, is anyone else available to look at this? I can't really even consider it for PDT+ without a patch.
This is due to the selected index not being set until the frame is loaded. It is fixed in the patch for bug 34297. Adding dependency.
Depends on: 34297
interestingly if the size attribute is removed the selectedindex is set to 0
Fixed with bug 34297 landing.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
*** Bug 101720 has been marked as a duplicate of this bug. ***
verified 2001-11-09-09
Status: RESOLVED → VERIFIED
Reopening bug. Failed on win2k build 2001-11-26 build
Status: VERIFIED → REOPENED
Resolution: FIXED → ---
this bug is a regression from 2001-11-09-09. adding the keyword regression
Keywords: regression
Worksforme build 2001120303 win2k. In the testcase it alerts Success! 6 - 6 and document.writes 6.
Works for doron and jesus_X on #mozillazine as well in recent nightlies
WFM.
Status: REOPENED → RESOLVED
Closed: 23 years ago23 years ago
Resolution: --- → WORKSFORME
verified build 2001-12-07-10.
Status: RESOLVED → VERIFIED
Keywords: regression
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: