Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Looping though multiple fields - misnamed as [Javascript] Named Layers in IE
- From: javascript@xxxxxxxxxx (TomMallard)
- Subject: Looping though multiple fields - misnamed as [Javascript] Named Layers in IE
- Date: Mon, 27 Aug 2001 13:20:03 -0700
Correct, you have to add the tests for those cases and handle them
separately.
if(typeOf(document.Form1.MyField[i]) != 'object'){
...there are 0 or 1 so use name...
if(document.Form1.MyField.name == 'someName'){
var strName = document.Form1.MyField.value;
}
}else{
var arrMyField = document.Form1.MyField;
if(arrMyField.length>0){
for(i=0;i<arrMyField.length;i++){
...process arrMyField[i].name...
}
}
}
tom
----- Original Message -----
From: "Lau" <lau@xxxxxxxxxxxxxxxx>
To: <javascript@xxxxxxxxxx>
Sent: Monday, August 27, 2001 11:40 AM
Subject: Re: Looping though multiple fields - misnamed as [Javascript] Named
Layers in IE
> 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@xxxxxxxx>
> To: <javascript@xxxxxxxxxx>
> 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@xxxxxxxxxxxxxxxx>
> > To: <javascript@xxxxxxxxxx>
> > 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@xxxxxxxxxx
> > > http://www.LaTech.edu/mailman/listinfo/javascript
> > >
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript@xxxxxxxxxx
> > http://www.LaTech.edu/mailman/listinfo/javascript
> >
> >
>
> _______________________________________________
> Javascript mailing list
> Javascript@xxxxxxxxxx
> http://www.LaTech.edu/mailman/listinfo/javascript
>
- References:
- [Javascript] Named Layers in IE
- From: Jay Lepore
- [Javascript] Named Layers in IE
- From: Lau
- [Javascript] Named Layers in IE
- From: TomMallard
- Looping though multiple fields - misnamed as [Javascript] Named Layers in IE
- From: Lau
- [Javascript] Named Layers in IE
- Prev by Date: Looping though multiple fields - misnamed as [Javascript] Named Layers in IE
- Next by Date: [Javascript] Form value
- Previous by thread: Looping though multiple fields - misnamed as [Javascript] Named Layers in IE
- Next by thread: [Javascript] Form value
- Index(es):