[Javascript] Defining the Name of a Variable at Runtime

Dan Costea costea at ssi-schaefer-noell.com
Wed Feb 6 14:14:58 CST 2002


I don't think it is possible (but I don't know for shure). But you can do a
little trick: define a global variable:
var arrGlobalImgs = new Array ();
Then, when you whant to create a runtime variable, you write:
arrGlobalImgs[ "a" + i ] = new Image( 214, 39 );
When you want to call it, you will write: arrGlobalImgs[a2] (for example).





----- Original Message -----
From: <gregory.john.toland at census.gov>
To: <javascript at LaTech.edu>
Sent: Wednesday, February 06, 2002 7:48 PM
Subject: [Javascript] Defining the Name of a Variable at Runtime


> Is it possible to define the name of a variable at runtime?  I would like
> to create variables a1...a100 like....
>
> eval( "a" + i ) = new Image( 214, 39 );
>
> Is this possible?
>
> Gregory J Toland
> Sr. Systems Architect





More information about the Javascript mailing list