Posted by Jonathan N. Little on 11/06/05 18:54
sagejoshua wrote:
> Help!
>
> Is there a way to declare a variable name using other variables in
> Javascript? In PHP, it's done with something like:
>
> <?php
>
> $var1 = "foo";
> ${$var1.bar} = "great!";
>
> print $foobar;
>
> // Outputs "great!"
>
> ?>
>
> Is there a similar method in Javascript?
>
> Thanks.
> Josh
var foo="Value of Foo";
var bar="foo";
alert( "foo=" + foo + "\n evail of bar=" + eval(bar) );
--
Take care,
Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
[Back to original message]
|