View Full Version : DomQuery out of wack ?? Unless I'm doing something stupid...

6 Aug 2009, 5:52 AM
Looks like a simple thing but...

Here is the problem.

I have a form with 10 fields that look like this:

<input type="text" name="FUserName" id="FUserName" autocomplete="off" size="20" class=" x-form-text x-form-field italique" style="width: 124px;"/>I'm trying to select all the fields using Domquery. Here is the code:
Note that all my fields start with a capital "F".

var myFields = Ext.DomQuery.select("input[name^=F]");
for ( var i in myFields ) {
alert( myFields[i] );

This is a pretty straightforward thing, it works (somewhat) but not only it returns all the fileds elements but it returns like 10-20 Javascript functions source ???

It this a bug or me that is doing something wrong ?

Whoever can shed some light on that mystery is welcome !

Altamirador !

6 Aug 2009, 6:04 AM
You are enumerating all properties of an Array (which includes elements, but also some functions and the length property).

You should have used:

for(var i = 0, len = myFields.length; i < len; i++){