Re: Enumerating input fields

anthyon
Thu, 22 May 2008 13:58:41 -0000

i tried what you mentioned, but i have a problem with the "0" in the
sortby. the elements in the collection without tabindex are returned
in a random way, instead of in document order. :(

looking at the Form#getElements method it says:

"getElements(formElement) -> array" -> which i suppose to mean
is
ordered
"Returns a collection..." -> which is not ensured to be ordered

so if this method returns ordered list, then i just have to reindex
the elements with tabindex.

but if not, how can i find out easily the document order of elements?

Anthyon

Martin Ström írta:
> Not really tested but something like this should get you started:
>
> $(''my_form'').getElements().sortBy(function(element) {
>   return parseInt(element.readAttribute(''tabindex'') ||
0);
> }).each(function(element) {
>   // do something
> });
>
> /Martin
>
> 2008/5/22 anthyon <anthyon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> >
> > Hi all,
> >
> > I''m just wondering if there''s a way to enumerate a
form''s input fields
> > (and selects and etc) in tab order. Is there a standard or a
> > prototypish way to do this?
> >
> > Anthyon
> > >
> >
>
>
>
> --
> burnfield.com/martin