Basically I want to increment the name of the variable. What is the correct syntax to do this?
for (i=0; i<5; i++) {
eval("var slider_" + i);
var slider_+i = function(){
//some code
}
dojo.addOnLoad(slider_+i);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Why not just use an array?
Alternatively, you could access them based on the object they are contained within. Assuming they are global variables (hopefully not):
window["something"]is another way to access a global variable namedsomething.