[Javascript] variable whose name is the result of a calculation?
charlie_chan
charlie_chan at cox-internet.com
Wed Dec 11 12:13:54 CST 2002
The entire code would help a lot! Not enough info here to understand what
you are doing.
----- Original Message -----
From: "Anthony Webster" <awebster at venda.com>
To: <javascript at LaTech.edu>
Sent: Wednesday, December 11, 2002 5:50 AM
Subject: [Javascript] variable whose name is the result of a calculation?
hi all,
I want to define a new variable, whose name is the result of a calculation.
does this make sense? a simple example follows
var1 = 'ora';
var2= 'nge';
var3 = var1 + var2;
// result:
// var3 = 'orange';
eval(var3) = '263';
// intended result:
// orange = '#FB8E36';
of course when I do this, javascript is not happy. it doesnt like the left
hand side with the 'intended result' bit.
why am I doing things like this? I am going to be supplied the names of the
colours without knowing what they will be. I will need to evaluate what they
are and then declare variables for each of them so I can reuse this
information.
any help would be greatly appreciated!
thanks,
anthony
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list