>> If myElem is the ID of the form, that will containt all the child
>> nodes, you will then iterate over all of them.  To get just the
>> controls with the same name:
>>
>>   var controls = $('myElem').elements;
>
>This is completely Prototype syntax. In jQuery it looks like:
>
>var controls = $('#myElem')[0].elements;

One thing to be aware of (and I just spent a bunch of time on this
yesterday) is that in IE6, $('#myElem')[0].elements is really a reference to
the form element itself. 

The "elements" property is *supposed* to be an array of form controls in the
form, but in IE6 since the form element itself can be treated as an array,
the "elements" property looks to be just a reference to the form element
itself.

This might be best exampled by doing:

alert(
        document.getElementById("myElem").elements 
                ==      
        document.getElementById("myElem")
);

If you run the above code in FF, you'll get false. If you run the code in
IE6, you'll get true.

This means if you really want a reference to the elements array, you'll need
to copy it to another array both passing it to jQuery for IE6 support--that
way you're dealing with a real array and not a reference to a special IE
object.

-Dan

PS - I'm trying to see if there's a way to detect a difference between
document.getElementById("myElem").elements and
document.getElementById("myElem") in IE6 so we can handle this automatically
in jQuery v1.1.3. However, since it appears to be a direct reference to the
form object itself, there appears to be no way to differentiate between the
two.

Reply via email to