Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • From: javascript@xxxxxxxxxx (Rodney Myers)
  • Subject: [Javascript] I don't know what to put down as the subject for this one...heh...
  • Date: Mon, 29 Jul 2002 09:57:27 +0100

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

SnarfLT@xxxxxxx 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