...

View Full Version : Defining variable names at runtime..



hymanroth
06-15-2006, 05:06 PM
Hi, does anybody know whether it's possible to create variable names at runtime.

For example

DEFINE? ('bob')

would create a variable named 'bob'.

I played around with eval for a while, but didn't get very far...

Thanks...

vwphillips
06-15-2006, 07:52 PM
window['auniquestring']='anyoldvalue'

Beagle
06-15-2006, 08:28 PM
There is only runtime in javascript.

There are no constants, macros, or preprocessor symbols.

So what vwphillips just recommended is a way of creating a global variable. You must allocate memory for it, no way around it.

Also to clarify, you can then use the above example like so:

alert(auniquestring);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum