PDA

View Full Version : eval()uating for a variable...


Eternity Angel
11-08-2002, 11:05 AM
I have no clue on how to do this, but I THINK that it's possible...

I have an input that takes it's value to a function, then I need to turn the value of that into a variable, and change that variable.

The value would be "something", and the variable would be "something1" - How would I eval()uate it so I could change the variable "something1"?

What I thought would work returns some new error to me:


eval(a+"1") = 12;


as an example, where "a" is the value (something).

What is the correct way to do this...?

glenngv
11-08-2002, 11:28 AM
eval(a+"1 = 12");

so if a = "something" and you have a variable named something1, the string to be evaluated would look like:

eval("something1 = 12");

that will put 12 as the value of something1

Eternity Angel
11-08-2002, 11:32 AM
Thank you!

I had been playing around, trying to get this for the past 30 minutes, and just as you responded, I got it.

Thank you anyways :)

joh6nn
11-08-2002, 09:34 PM
personally, i hate using eval() if i don't have to.

window[a+"1"] = 12;