Results 1 to 1 of 1
Thread: Javascript problem
-
11-04-2003, 08:07 PM #1Hail Eris !
- Join Date
- Oct 2002
- Location
- Canada
- Posts
- 3,103
Javascript problem
I usualy do not use JS if it can be avoided, but I need it now, and I am stuck a bit.
testStart = 1 ;
testStop = 1 ;
function someTest (arg) {
var somevar = eval ( 'test' + arg ) ;
// this sets somevar to have value of testStop if arg passed to function was 'Stop'
what I would like to do is to increment value of testStop for 1 , so the next time this function is called, testStop has value of 2 . This example is typed just for this post. In real life there is varable number of vars (testStart, testStop ....). Is there a way to do this without using if statements. Maybe something like:
refvar = referenceToVariableCalled ('test' + arg) ;
refvar ++ ;
... and this would increse value of testStop for 1
}
Thanks for reading