Dynamic variable name

Hello,

I would like to create dynamic variable name and assign values to them.
Something like this:

var item1 = “adf”;
var item2 = “wer”;
:
var item’n’ = “xyz”;

i want to create these names dynamically.

i tried: var item{i} where i is the dynamic variable.
var item[i]
var item(i)
nothing seems to be working.

I also tried:
eval(‘item’+i) - it gives ‘item1’ is undefined.
It doesnt recognize : var eval(‘item’+i)

Any idea ??

Thanks
J

An array is what you want to be using for dynamic variables. See my example below

var item = new Array();
item['test'] = 'Hello';
item['test2'] = 'Hello Again';

alert(item['test']);

Hope that helps bud