You are here: Re: Help with Javascript: naming variables using other variables « HTML « IT news, forums, messages
Re: Help with Javascript: naming variables using other variables

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация