|
Posted by X l e c t r i c on 11/06/05 19: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 =3D "foo";
${$var1.bar} =3D "great!";
print $foobar;
// Outputs "great!"
?>
Is there a similar method in Javascript?
Thanks.
Josh"
Are you sure that outputs "great!" ?
Jonathan=A0N.=A0Little wrote:
"var foo=3D"Value of Foo";
var bar=3D"foo";
alert( "foo=3D" + foo + "\n evail of bar=3D" + eval(bar) );"
There's no need for eval (or evail):
var foo =3D "Value of Foo";
var bar =3D foo;
alert("foo =3D " + foo + ".\n\nBecause the value of the variable bar now
equals the value of the variable foo, bar also =3D " + bar + ", without
the need of eval.");
Later, Art.
Navigation:
[Reply to this message]
|