Closed Bug 86659 Opened 24 years ago Closed 24 years ago

alteration of select widget by JavaScript broken

Categories

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

defect
Not set
major

Tracking

()

VERIFIED FIXED

People

(Reporter: chris+bugzilla, Assigned: jst)

References

()

Details

Attachments

(1 file)

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.
Confirming bug on WinNT 20020615xx. Platform/OS : Mac --> All. Browser, not engine; reassigning to DOM Level 0. Here is the HTML from the testcase: <html> <head> <script> var values = new Array('item1','item2','item3'); var labels = new Array('Item 1','Item 2','Item 3'); function changeSelects(form, newval) { // empty select, then load select form.sel.length = 0; form.sel.options[0] = new Option("select an item"); form.sel.options[0].value = "none"; var x = 1; var sel = 0; for (opt in values) { form.sel.options[form.sel.options.length] = new Option(labels[opt]); form.sel.options[x].value = values[opt]; if (values[opt] == newval) { sel = x; } x++; } form.sel.options[sel].selected = "true"; } </script> </head> <body> <form> <select name=sel> <option value=none>Empty select</option> </select> <input type=button name=ChangeSelects value=ChangeSelects onClick="changeSelects(this.form, 'item2')"> </form> </body> </html>
Assignee: rogerl → jst
Status: UNCONFIRMED → NEW
Component: Javascript Engine → DOM Level 0
Ever confirmed: true
OS: Mac System 9.x → All
QA Contact: pschwartau → desale
Hardware: Macintosh → All
Compare bug 86287, where the addition of an alert changes the DOM behavior.
With the testcase in the URL bar, the selected element is correctly reported into the DOM, but the change is not done in layout it seems. While in the second attached testcase, the alert dialog will cause a reflow apparently. I wonder whether this should not rather go to html form controls. CC'ing rods
oh of course I forgot to mention this is probably due to rods checkin for bug 53165
Is the same as/related to bug#61628, which is also concerned with javascript selecting options?
Between trunk builds 20010720xx and 2001072408 there was further regression on this bug. In the sample URL (see attachment), now not only does the select not set properly, the select does not fill as it did before. Upon pressing button the select empties.
Since posting that last note, and a browser restart, I've had the attached 6/19 test succeed, fail and succeed again. I've done enough activities, between browsing, switching apps, reading mail, etc. that I can't identify a trigger. I get a JS error of "Error: cmd_delete is not defined" when the new bug appears however. Hope this helps...
Is there a workaround for this bug besides displaying an alert dialog between the creation of the option and its selection?
As of today's build (2001081708), this bug is fixed for me (the reporter). Thanks to everyone who worked on this bug! From my point of view, the resolution of this bug makes Mozilla eligible for v1.0. Chris
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Verified on 2001-08-28-09-trunk on Win-95.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: