[Javascript] dynamic var names

Troy III Ajnej trojani2000 at hotmail.com
Tue Aug 7 16:18:58 CDT 2007


My understanding is that you are trying to asign a value to the value!
 
You've created a var myDynVar not a var foo, that is, you can't alert 
the "foo" because it's the value of your myDynVar var. If you call the
myDynVar it will alert its last asigned value.
 
That is you don't need to make e dynamic var because dhe var values 
are dynamic by nature. 
If you start with te initial value of your myDynVar="foo" you cal change 
it any time by asignin a fresh value of your interest anywhere in your
script body. Saying: myDynVar="bar". After this instance your call to
alert(myDynVar) will bring you the value "bar" in the alert box. And after
this you can change it's value to any other continually as neded. The only 
precaution to take before this is to declare your "myDynVar" as global var.
 
But if you need several coexisting values of your var, you better try using
object.
 
Regards~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                        Troy III                            progressive art enterprise~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


From: list at tridemail.deTo: javascript at LaTech.eduDate: Tue, 7 Aug 2007 11:12:34 +0200Subject: [Javascript] dynamic var names



I dynamically create a name for a var, let's say
 
var myDynVar    = 'foo';
 
Now I want to fill (var) foo with a value f.e. 'bar', so the next time I
 
alert(foo)    results in => bar;
 
I tried several combinations with eval() but still didn't get it. Can anyone help?
 
 
 
 
MfGMichael BorchersTridem GmbHhttp://www.tridem.demailto: borchers at tridem.deTel.: 0491 / 96 06 71 63ICQ: 322766923
_________________________________________________________________
Recharge--play some free games. Win cool prizes too!
http://club.live.com/home.aspx?icid=CLUB_wlmailtextlink
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20070807/4606055a/attachment.htm>


More information about the Javascript mailing list