[Javascript] strings into variables

Peter Brunone peter at brunone.com
Wed Aug 1 10:41:05 CDT 2001


David,

    Read up on the eval() function.  It can take a string and turn it into the appropriate object reference, e.g.

var myPointer = eval("document.all.myDiv.style.color");

    Should be what you're looking for.

Cheers,

Peter
  ----- Original Message ----- 
  From: David Levy 
  To: javascript at LaTech.edu 
  Sent: Wednesday, August 01, 2001 10:02 AM
  Subject: [Javascript] strings into variables


  Hi, I'm trying to turn a string into a variable name.  In other words, suppose I get input from a user, and want to convert that string into a name of a variable and use it in a function.  The reason I have for doing this is that the input I get from the user will be an actual preexisting variable name in the script, but there are very many of these variables and I'd like to refer to them without using switches.  I hope this was clear and please tell me if you need clarification.

  David Levy.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20010801/cf3e8639/attachment.htm>


More information about the Javascript mailing list