Hi Narendra, I'm wondering why you use toString() method here?
I think 'value_at_' + i would also work fine On Jun 9, 10:09 pm, Narendra sisodiya <naren.sisod...@gmail.com> wrote: > try to use object like this: > > var myObject={}; > var count=10; > > for(var i=0;i<count;i++) > { > myObject['value_at_'+i.toString()]="value at "+i.toString(); > > } > > or > assign value like > var index=5; > myObject['value_at_'+index.toString()]=" this is value at 5"; > > alert(myObject['value_at_5']); //display "this is value at 5" > > ~N a R e N > > On Tue, Jun 9, 2009 at 8:14 PM, waseem sabjee <waseemsab...@gmail.com>wrote: > > > > > sorry i had a syntax error > > > heres the code > > see just declare an array > > declare the maximum number you want > > > then loop through them one by one asigning a number to each one :) > > > var myVar = new Array(); // declare array > > var myvarcount = 10; // maximum vars > > > for(var i = 0; i < myvarcount; i++) { // simple for loop > > > myVar[i] = "I am number : " + i; // assign values to each one in the loop > > } > > > alert(myVar[6]); // this will alert the sixth value > > alert(myVar[0]); // also note an array can start from 0 > > > On Tue, Jun 9, 2009 at 4:42 PM, waseem sabjee <waseemsab...@gmail.com>wrote: > > >> Why not use an array ? > > >> var myVar = new Array(); > >> var myvarcount = 10; > > >> for(int i = 0; i < myvarcount; i++) { > > >> myVar[i] = "I am number : " + i; > > >> } > > >> On Tue, Jun 9, 2009 at 4:35 PM, simon <si...@uvfx.tv> wrote: > > >>> I have some simple variables > > >>> $.myvariable1 > >>> $.myvariable3 > >>> $.myvariable2 > > >>> now I would like to add the number part of the variable to it > >>> dynamically. > > >>> var i=1 > > >>> $.myvariable+i > > >>> and so on, whats the way I could do this, i have tried several like > >>> $.myvariable[i] etc but nothing > > >>> Si