[Javascript] I don't know what to put down as the subject for this one...heh...

Rodney Myers rodney at aflyingstart.net
Mon Jul 29 03:57:27 CDT 2002


You need to use the eval() function
eval("document.mainForm.service"+i+".value = myValue");
hth
Rodney

SnarfLT at aol.com wrote:

> I am creating a user-defined-number -> (x) of input text boxes on the
> fly.
> giving them each the name service(1 - x)
> example:
> name=service1
> name=service2
> name=service3
> ...
> name=servicex
>
> I want to write to these boxes using the following for loop:
>
> for (i = 1; i <= x; i++)
> {
>   document.mainForm.service+i+.value = "myValue";
> }
>
> ...obviously that doesn't work, so i tried this:
>
> for (i = 1; i <= x; i++)
> {
>   temp = "document.mainForm.service"+i+".value
>   temp = "myValue";
> }
>
> that didn't work either.  I wanted to avoid using ID's but it looks
> like I have to, unless any of you can point me in another direction.
>
>
> Thank you for your time,
> Scott





More information about the Javascript mailing list