Eternity Angel
10-30-2002, 02:40 PM
I cannot figure how to do this, probably because I don't really know much about eval() for JS, although I know HOW it is supposed to work.
Anyways, I have Arrays that are called:
dirs1,
dirs2,
dirs3, and
dirs4
What I need to do, is make ANOTHER variable, which I am calling "dir", which contains the same value as one of those dirsX variables would. I have a random number between 1 and 4, and I am not sure how to make it so the "dir" variable will be almost identidal to the dirsX variables, by calling through dir[#], instead of dirsX[#].
I have no clue what I just said either, so, let me paste what I am trying to do, maybe IT will provide a better explaination.
var random = Math.floor(Math.random()*(5-1)+1);
var dir = eval("dirs"+random);
alert(dir[0]);
Is this even possible? I get an "undefined" when I alert() the value of dir, and an "dr.1 is undefined" if I alert() dir[0].
If you didn't understand the question I had in there, then, MAYBE I could try to repeat it...
Anyways, I have Arrays that are called:
dirs1,
dirs2,
dirs3, and
dirs4
What I need to do, is make ANOTHER variable, which I am calling "dir", which contains the same value as one of those dirsX variables would. I have a random number between 1 and 4, and I am not sure how to make it so the "dir" variable will be almost identidal to the dirsX variables, by calling through dir[#], instead of dirsX[#].
I have no clue what I just said either, so, let me paste what I am trying to do, maybe IT will provide a better explaination.
var random = Math.floor(Math.random()*(5-1)+1);
var dir = eval("dirs"+random);
alert(dir[0]);
Is this even possible? I get an "undefined" when I alert() the value of dir, and an "dr.1 is undefined" if I alert() dir[0].
If you didn't understand the question I had in there, then, MAYBE I could try to repeat it...