how to create variable name dynamically?
eg: if (test==1)
var test1=1
if (test==2)
var test2=2

here test1 and test2 should create dynamically.
i tried

var "test"+1.
But throws error.
Any idea?

I could do it using eval() function; however it is a really bad design to create it dynamically. You will have a hard time maintenance your script and other things else in the future. Use array to hold on your data instead of create new variable each time...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.