javascript select on multiple select box is malfunctioning

RESOLVED WORKSFORME

Status

()

Core
DOM: Core & HTML
RESOLVED WORKSFORME
17 years ago
17 years ago

People

(Reporter: David Anderson, Assigned: jst)

Tracking

Trunk
x86
All
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
Recently javascripted form.select[val].selected = true; calls are getting wiped
away in 9.2.

See for yourself: http://www.aocsolutions.com/show_moz_select_error.html

Comment 1

17 years ago
Here is a synopsis of the HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
 <title>Untitled</title>
</head>

<body>

<form name="f" id="f">
  <select name="s" id="s" multiple="multiple">
      <option>0</option>
  </select>

  <input type="button" 
         value="try it" 
         onclick="document.f.s.length += 1; 
                  document.f.s[document.f.s.length-1].text = 'select me'; 
                  document.f.s[document.f.s.length-1].selected = true; 

                  for (var c=document.f.s.length-1; c >-1;c--) 
                    alert (c + ' is selected ? ' +  document.f.s[c].selected); 

                  for (var c=document.f.s.length-1; c >-1;c--) 
                    alert (c + ' is selected ? ' +  document.f.s[c].selected);" 
  />

</form>
</body>
</html>

Comment 2

17 years ago
Reduced testcase: 


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
 <title>Bug 89425</title>
</head>

<body>

<form name="f" id="f">
  <select name="s" id="s" multiple="multiple">
      <option>Option 0</option>
      <option>Option 1</option>
      <option>Option 2</option>
  </select>

  <input type="button" 
         value="try it" 
         onclick="document.f.s.length += 1; 
                  var len = document.f.s.length;
                  document.f.s[len - 1].text = 'Option ' + (len -1);
                  document.f.s[0].selected = true;" />

</form>
</body>
</html>
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 3

17 years ago
Created attachment 41291 [details]
Reduced testcase

Comment 4

17 years ago
The reduced testcase is trying to select the topmost option in the 
selectbox. This works in NN4.7, but not in Mozilla 20010628xx.


If we remove these three lines of code: 

                  document.f.s.length += 1; 
                  var len = document.f.s.length;
                  document.f.s[len - 1].text = 'Option ' + (len -1);


Then the selection of the topmost option works just fine: 

                  document.f.s[0].selected = true;


Somehow the first three lines are preventing the fourth line from working.
Reassigning to DOM Level 0 for further analysis - 
Component: Javascript Engine → DOM Level 0
OS: Windows NT → All

Comment 5

17 years ago
Really reassigning -
Assignee: rogerl → jst
QA Contact: pschwartau → desale

Comment 6

17 years ago
again the same bug about selected = true, probably a dup of bug 86659

Comment 7

17 years ago
This is WFM on 0.9.4 and 2001092113 Linux.  The first option gets selected after
the last option is added.
Status: NEW → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.