Incrementing variable name NOT the value of the variable itself.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   jayne_fly
Posted On:   Monday, October 20, 2003 11:38 PM

I am looking for a way to generate a variable name that is incremented as the code goes through a loop. I am not looking for a way to increment the value of the variable. Rather, I need to increment the variable name. ie: var1, var2, var3.... I am using a database query on the server, this stores the information in an array. I need to run a loop within a loop. And I would like to be able to increment the variable name in the following way.... for (var i = 0; i <"#1stQuery.recordcount#"; i++) { var varname[i] = new WebFXTreeItem( query1_results[i] ); tree.add(varname[i]); for (var j = 0; j <"#2ndQuery.recordcount#"; j++) {    More>>

I am looking for a way to generate a variable name that is incremented as the code goes through a loop. I am not looking for a way to increment the value of the variable. Rather, I need to increment the variable name. ie: var1, var2, var3....

I am using a database query on the server, this stores the information in an array.

I need to run a loop within a loop. And I would like to be able to increment the variable name in the following way....




			

for (var i = 0; i <"#1stQuery.recordcount#"; i++) {

var varname[i] = new WebFXTreeItem( query1_results[i] );
tree.add(varname[i]);


for (var j = 0; j <"#2ndQuery.recordcount#"; j++) {

var varname[j] = new WebFXTreeItem( query2_results [j] );
varname[i].add(varname[j]);
}


}


Any help would be great.

Thanks,
Jayne    <<Less

Re: Incrementing variable name NOT the value of the variable itself.

Posted By:   Firat_Tiryaki  
Posted On:   Tuesday, October 21, 2003 04:37 AM

Try this, I hope it will give you an idea



eval("var"+1+"=125");
alert(var1);
About | Sitemap | Contact