Closed Bug 236539 Opened 20 years ago Closed 17 years ago

The text of an option tag remains the older when I remove one of an option on others

Categories

(Core :: Layout: Form Controls, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 286170

People

(Reporter: samuzeau, Unassigned)

Details

(Keywords: qawanted, testcase)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7a) Gecko/20040219
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7a) Gecko/20040219

I have :

<option>1</option>
<option>2</option>
<option selected="selected">3</option>

When I do remove the second child of the select, I have:

<option>1</option>
<option selected="selected">3</option>

I change the text of the option, it becomes:

<option>1</option>
<option selected="selected">2</option>

It must display 2 at the screen, but in Mozilla, it display still 3.

Reproducible: Always
Steps to Reproduce:
1. I create the Select tag (in a TD)

// The var IDLine is the choice of the user, it's an increment one by one
var newtdselect = document.createElement("td")
var newselect = document.createElement("select")
newselect.setAttribute("id","HR"+IDLine)
newselect.setAttribute("name","HR"+IDLine)

for (i=1;i<=IDLine;i++)
 {

 var newoption = document.createElement("option")
 newoption.setAttribute("id",i)
 newoption.setAttribute("class","classoption1")
 if (i == IDLine)
  {
   newoption.setAttribute("selected","selected")
  }
 var newtxt = document.createTextNode(i)
 newoption.appendChild(newtxt)

 newselect.appendChild(newoption)
 }

// Here I must upgrade the other Select, in other TD
// I do it by create a new child option in the Select Tag

if (i>2)
 { 
   for (j=1;j<=i-2;j++)
    {
     var newoption = document.createElement("option")
     newoption.setAttribute("class","classoption1")
     newoption.setAttribute("id",IDLine)
     var newtxt = document.createTextNode(i-1)
     newoption.appendChild(newtxt)
     document.getElementById("HR"+j).appendChild(newoption)
    }
 }

newtdselect.appendChild(newselect)

newtr.appendChild(newtdselect)

2. The user create 3 Select Tag

3. Now, We delete one of the TD(entirely), and the Select disappear

// Here NumLine remain the numbre of Select include
// IDLine is the line that the user want to delete

for (i=1;i<=NumLine;i++)

 {
  if (i != IDLine)
    {
     noeud = document.getElementById("HR"+i)[IDLine-1]
     document.getElementById("HR"+i).removeChild(noeud)
     for (j=0;j<=NumLine-2;j++)
      {
       noeud = document.getElementById("HR"+i)[j]
       k=j+1
       noeud.setAttribute("id",k)
       if (k == NumLine)
         {
          noeud.setAttribute("selected","selected")
         }
       depart = 0
       taille = noeud.firstChild.nodeValue.length
    document.getElementById("HR"+i)[j].firstChild.replaceData(depart,taille,j+1)
       noeud = document.getElementById("a"+i)
       noeud.setAttribute("href","javascript:DeleteLine("+k+")")
      }
    }
 }

NumLine--


for (i=IDLine;i<=NumLine;i++)
 {
 k=i+1
 noeud = document.getElementById("HR"+k)
 noeud.setAttribute("id","HR"+i)
 }

Actual Results:  
I assume that:
1. The user has created 3 Select Tag
2. He removed one of them, the number 2

The display show the Select Tag : 3 (but I can choose only 1 or 2 as options)

Expected Results:  
The display must show : 2 ( The last selected option)

about:buildconfig

Build platform
target
i586-pc-msvc

Build tools
Compiler 	Version 	Compiler flags
$(CYGWIN_WRAPPER) cl 	12.00.8804 	-TC -nologo -W3 -nologo -Gy -Fd$(PDBFILE)
$(CYGWIN_WRAPPER) cl 	12.00.8804 	-TP -nologo -W3 -nologo -Gy -Fd$(PDBFILE)
-I/usr/X11R6/include

Configure arguments
--without-system-jpg --without-system-zlib --enable-extensions=default,irc,tasks
--enable-crypto --disable-auto-deps --disable-debug --enable-optimize=-O1
Please make a small testcase that shows the problem and attach it using:
http://bugzilla.mozilla.org/attachment.cgi?bugid=236539&action=enter
What to do, what to see.

1- You can add 3 TR tag by clicking on "Click here to add a TR Tag"
2- You can remove one TR tag (the second) by clicking on the last TD you want
to delete ( the alt is "Detete the TR Tag")

3- As you see, in the now second TR (the old third TR), we should see the
number 2 (the number of TR) and not the number 3 which remains.
This needs a SMALL testcase.  Something under 500 bytes should probably be
sufficient.
Keywords: qawanted
I see this using the testcase on LInux 2004033007
OS: Windows XP → All
Keywords: testcase
This got fixed by the fix for bug 286170.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → DUPLICATE
Checked in the test (slightly simplified) into reftest.
Flags: in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: