Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create javascript variables on the fly

Status
Not open for further replies.

ryanbrand

Programmer
Oct 28, 2003
22
US
Hi,
I would like to create an undefined number of variables as my page loads.
I want to use numbers to change the name of the variable. Here's how it would work:
1. declare variable
2. create new variables in a loop

Afterward I would have a list of variables depending on how long the loop goes:
myVar1
myVar2
myVar3

I would have each store a different value determined by it's number.

Is there any way I can do this?

Thank you for your help!

Ryan
 
why not just use an array?

-kaht

banghead.gif
 
Check out faq216-3858

Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life=life-1};
 
An array will work perfectly. I don't know why I didn't think of that. Thanks a lot.
Ryan
 
Adam, I think you have a faq for everything. :)

-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top