View Full Version : form.findField finding a field with the same id outside the form
topcoder1
08-23-2007, 05:19 PM
I have two input elements with the same name and id 'my_input_id' in two separate forms form a and form b. The forms have different ids. I verified these from dom inspector on ff.
for some reason b.findField('my_input_id') returns the actual field from form a. is this expected or a bug?
or maybe it's just me..
devnull
08-23-2007, 06:36 PM
Its not just you, i had the same problem when using domQuery, even though my selectors were unique ("#div1 #myform #myfield" vs "#div2 #myform #myfield"). I just chalked it up as a css selector bug/feature, gave my fields unique values and moved on.
mystix
08-24-2007, 02:04 AM
according to the W3C specs (http://www.w3.org/TR/html401/struct/global.html#h-7.5.2), with regard to a tag's id
This attribute assigns a name to an element. This name must be unique in a document.
i.e. html tag ids must be unique within the DOM.
tag names on the other hand, need not be unique.
topcoder1
08-24-2007, 02:12 AM
I just let these input elements have the same name, but not assigning them ids manually, this way it's still ok when their values are passed to the server.
mystix
08-24-2007, 03:08 AM
ahh.. that'll work.
u could also use Ext.id() to generate unique ids for dynamically created HTMLElements too.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.