Skip to main content
Participant
February 22, 2011
Question

using a variable as an identifier

  • February 22, 2011
  • 1 reply
  • 980 views

Hi,

Lets say I have 5 text boxes that are named t1, t2, t3 etc. I would like to use the variable "i" in the array below as part of the identifier to populate the field is this possible to use an incrementing variable as part of the instance identifer? If so can you help with the syntax I can't get it to work for me.

for(var i = 0; i < 5; i++) {
t(i).text = i;
}

Thanks,

UglyFrank

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
February 22, 2011

use array notation:


for(var i = 0; i < 5; i++) {
this["t"+i].text = i;
}


uglyfrankAuthor
Participant
February 22, 2011

sorry meant to click the correct answer, I am such a newbie from dumbasscass!

kglad
Community Expert
Community Expert
February 22, 2011

lol.  no problem.