Hey, I’ve been working on a script for a few hours here that’s just got me bugged!
I have several variables in a file called statelist.js which is linked at the top of my file:
[code=html]
var state1 = “alabama”;
var state2 = “alaska”;
var state3 = “arizona”;
then, on my main page I am trying to concatenate the word “state” with a looping number in a while statement:
[code=html]
var c = 1;
while(c <= 3) {
var getState = “state”+c;
alert(getState);
c++
}
Of course, with the quotes around it Alert just prints “state1” but without the quote it tells me state is undefined, but of course, I don’t want state, I want state1, state2, etc. which are defined.
Does anyone know what I need to do to concatenate the word state with the looping variable “c” to produce “Alabama” when alerted?
Thanks!!