[Javascript] Text Field Arrays

TomMallard mallard at serv.net
Wed May 2 08:03:33 CDT 2001


Are the brackets in the name of a form element legal? Those are
operators...pretty certain they're not legal characters used as form element
names. Nice trick, but I think you need to rename them...like
'files_description_00', I've used this style for auto-numbering a lot.

tom
----- Original Message -----
From: "Jay Lepore" <admin at myinternethandyman.com>
To: <javascript at LaTech.edu>
Sent: Wednesday, May 02, 2001 5:31 AM
Subject: RE: [Javascript] Text Field Arrays


>
>
> I tried this Jeff,
>
> window.document.configurator.elements[elementNum].value=changeto;
>
> But it doesn't work. In this short example I showed you 6 text fields but
> there are many more fields in this form which have the potential to be
> changed over time. Thanks for the suggestion in any case.
>
> >> <form name='configurator'>
> >>   <input type='text' name='files_description[0]' size='18'
maxlength='30'
> >> onBlur='return nochanging(this, 0)'>";
> >>   <input type='text' name='files_description[1]' size='18'
maxlength='30'
> >> onBlur='return nochanging(this, 1)'>";
> >>   <input type='text' name='files_description[2]' size='18'
maxlength='30'
> >> onBlur='return nochanging(this, 2)'>";
> >>   <input type='text' name='files_description[3]' size='18'
maxlength='30'
> >> onBlur='return nochanging(this, 3)'>";
> >>   <input type='text' name='files_description[4]' size='18'
maxlength='30'
> >> onBlur='return nochanging(this, 4)'>";
> >>   <input type='text' name='files_description[5]' size='18'
maxlength='30'
> >> onBlur='return nochanging(this, 5)'>";
> >> </form>
> >>
> >> I want to populate the values of one of those text fields onBlur
> >so the value
> >> is predetermined so I wrote this:
> >>
> >> <script language='JavaScript'>
> >> function nochanging(elem,elementNum){
> >>
> >> var changeto;
> >>
> >> switch(elementNum)
> >>       {
> >>       case '1':   changeto="Home Top Left"; break
> >>       case '2':   changeto="Home Top Right"; break
> >>       case '3':   changeto="Property List Top Left"; break
> >>       case '4':   changeto="Property List Top Right"; break
> >>       case '5':   changeto="Sale Sheet Top Left"; break
> >>       case '6':   changeto="Sale Sheet Top Right"; break
> >>       }
> >>
> >>
>
>window.document.configurator.files_description[elementNum].value=changeto;
> >> }
> >> </script>
> >Elements in a form are already in a array. As is just about everything
else
> >in a page. Try changing the values like so:
> >
> >window.document.configurator.elements[elementNum].value=changeto;
> >
> >Hope this helps,
> >Jeff
> >
> >
> >~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >Jeff Walters   (314) 962-4024
> >
> >Cybermill Communications
> >8616 Joseph Ave
> >St. Louis, MO 63144
> >Jeff at cybermill.com
> >http://www.cybermill.com/
> >
> >
> >_______________________________________________
> >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