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
>
>
>

Reply via email to