Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] variable whose name is the result of a calculation?
- From: javascript@xxxxxxxxxx (Anthony Webster)
- Subject: [Javascript] variable whose name is the result of a calculation?
- Date: Wed, 11 Dec 2002 11:50:52 -0000
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 =3D 'ora'; var2=3D 'nge'; var3 =3D var1 + var2; // result: // var3 =3D 'orange'; eval(var3) =3D '263'; // intended result: // orange =3D '#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
- Follow-Ups:
- [Javascript] variable whose name is the result of a calculation?
- From: charlie_chan
- [Javascript] variable whose name is the result of a calculation?
- Prev by Date: [Javascript] Split
- Next by Date: [Javascript] Split
- Previous by thread: [Javascript] Split
- Next by thread: [Javascript] variable whose name is the result of a calculation?
- Index(es):