Closed Bug 101720 Opened 23 years ago Closed 23 years ago

selectedIndex has wrong value right after intialization

Categories

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

x86
All
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 88076

People

(Reporter: schoepf, Assigned: jst)

References

Details

Attachments

(1 file, 1 obsolete file)

I noticed that right after rendering page the selectedIndex field of a selection
form input is always set to 0 no matter which option element is selected by
default (it has index 1 in the example html code beneath). After initialization
(e.g. in onClick events), it has the correct value.

This html page reproduces this behavior:

<html>
<head>
<title>Selection Test</title>
</head>
<body>
<FORM NAME="Form">
<SELECT name="Select">
  <OPTION value="0">Index 0</OPTION>
  <OPTION value="1" selected>Index 1</OPTION>
  <OPTION value="2">Index 2</OPTION>
</SELECT>
Selected Index: 
<script type="text/javascript" language="JavaScript">
document.write("<input type=Button name=Button width=20 value=" +
document.Form.Select.selectedIndex + "
OnClick=document.Form.Button.value=document.Form.Select.selectedIndex>");
</script>
<P>Bug description: Value "Index 1" (corresponding to javascript index 1) is
selected by default, but the Javascript field .selectedIndex returns 0.
After initialization it returns the correct value (push the button to verify).
</form>
</body>
</html>
Over to DOM core.  ccing jkeiser.  More testcasy goodness. :)
Assignee: rogerl → jst
Component: Javascript Engine → DOM Core
QA Contact: pschwartau → stummala
Attached file Reporter's HTML testcase (obsolete) —
Is this the idea? We're getting document.Form.Select.selectedIndex
before the page has finished loading, but because the <SELECT> has
appeared higher up in the HTML, the <SCRIPT> should already see 
that Option 1 has been selected. Is that it? 

At any rate, that is what NN4.7 and IE4.7 do. When you load the 
testcase in these browsers, you see a "1" written on the input button.
In Mozilla, you see a "0" written...

Confirming with Mozilla 20010923xx WinNT; OS : Linux --> All
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Linux → All
This is fixed in bug 34297.  Strangely, it's not identical to bug 88076--this
one shows "0" before body onLoad and that one shows "-1".  *shrug* both are fixed.
Depends on: 34297
Attached file Fixed testcase
Attachment #50919 - Attachment is obsolete: true
*** Bug 105374 has been marked as a duplicate of this bug. ***

*** This bug has been marked as a duplicate of 88076 ***
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
*** Bug 108673 has been marked as a duplicate of this bug. ***
verified dup of bug 88076
Status: RESOLVED → VERIFIED
Component: DOM: Core → 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: