Looping though multiple fields - misnamed as [Javascript] Named Layers in IE

Lau lau at goldenweb.com.au
Mon Aug 27 13:40:15 CDT 2001


Thanks Tom,

Unfortunately this script doesn't handle the cases where the number of fields in 0 or 1.
I can add in the convoluted extra bits to handle these cases but I'm hoping there's another way.
I vaguely remmember reading something where they did this by looping through the collection rather
than an array.... any ideas?

Thanks
Lau


----- Original Message -----
From: TomMallard <mallard at serv.net>
To: <javascript at LaTech.edu>
Sent: Tuesday, August 28, 2001 4:07 AM
Subject: Re: [Javascript] Named Layers in IE


> If you have more than one element with the same name, when you use
> document.form1.MyField you get the collection, then loop through that to get
> the names.
>
> var arrMyField = document.Form1.MyField;
> if(arrMyField.length>0){
>     for(i=0;i<arrMyField.length;i++){
>         ...process arrMyField[i].name...
>     }
> }
>
> tom mallard
> seattle
> ----- Original Message -----
> From: "Lau" <lau at goldenweb.com.au>
> To: <javascript at LaTech.edu>
> Sent: Monday, August 27, 2001 10:21 AM
> Subject: Re: [Javascript] Named Layers in IE
>
>
> > I have a FORM that may have N fields with the same name.
> > How can I loop through them when I don't know how many there are... there
> may be none.
> >
> > something like this:
> >
> > for (i=1;i<N;i++){
> >   alert(document.Form1.MyField[i])
> > }
> >
> > Thanks in advance
> > Lau
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > http://www.LaTech.edu/mailman/listinfo/javascript
> >
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>
>




More information about the Javascript mailing list