elements disapear from form.elements collection after element id changes

RESOLVED INCOMPLETE

Status

()

Firefox
General
RESOLVED INCOMPLETE
11 years ago
8 years ago

People

(Reporter: Doru Petrescu, Unassigned)

Tracking

2.0 Branch
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [CLOSEME 2010-07-30], URL)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11


if I change the 'id' property of an element of a form, that element will dissapear from the form.elements collection when you try to access by its NAME.

before:
form.fieldinput2=[object HTMLInputElement]
form.elements.fieldinput2=[object HTMLInputElement]
form.elements[1]=[object HTMLInputElement]

after:

form.fieldinput2=undefined
form.elements.fieldinput2=undefined
form.elements[1]=[object HTMLInputElement]


please note that the field is accessed by its NAME and the fact that the ID was changed should not affect its NAME in any way.

also note that the element does not completely disappear from the form. it can still be accessed using its numeric index: form.elements[1] 

it does the same thing on both linux and windows.
IE6 tested and works correctly
mozilla 1.7 fails this stripped down test page, but in some more complicated pages appear to work while FF2 fails.



Reproducible: Always

Steps to Reproduce:

1. create a form
<form name=f1 id=f1>
<input name=fieldinput1 value=123456789>
<input name=fieldinput2 value=555666777 id=fieldinput2 >
</form>

2. change the ID: 
document.getElementById('fieldinput2').id = 'new_id_for_fieldinput2';

3. now, you get:
 f.fieldinput2=undefined             **WRONG**
 f.elements.fieldinput2=undefined    **WRONG**
 f.elements[1]=[object HTMLInputElement]  CORRECT


second case:
1. create the form
2. read the values of the fields
3. change the element ID
t. now, you get:
 f.fieldinput2=[object HTMLInputElement]          **CORRECT**
 f.elements.fieldinput2=undefined                 **WRONG**
 f.elements[1]=[object HTMLInputElement]          **CORRECT**
This bug was originally reported on Firefox 2.x or older, which is no longer supported and will not be receiving any more updates. I strongly suggest that you update to Firefox 3.6.6 or later, update your plugins (flash, adobe, etc.), and retest in a new profile. If you still see the issue with the updated Firefox, please post here. Otherwise, please close as RESOLVED > WORKSFORME
http://www.mozilla.com
http://support.mozilla.com/kb/Managing+profiles
http://support.mozilla.com/kb/Safe+mode
Whiteboard: [CLOSEME 2010-07-30]
Version: unspecified → 2.0 Branch
No reply, INCOMPLETE. Please retest with Firefox 3.6.8 or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.