Results 1 to 2 of 2

Thread: change string to var name

  1. #1
    Join Date
    Sep 2008
    Harrisonburg, VA

    change string to var name

    I am passing a string that happens to be a div name to my JS function and in my JS there is a variable with the same name as the string. I want to access that variable based on the div name that is passed.

    var findMe;
    findMe = "Test, Test, Test, Test";
    function getText(toGet)
    	var toReturn = toGet.toString(); //This sets toReturn to "findMe" I want it to set it as the value of findMe
    	return toReturn;
    Xtrme XJ
    "Vision without Action, Daydream
    Action without Vision, Nightmare"
    Japanese Proverb

  2. #2
    Join Date
    Jul 2008
    urbana, il
    you must be calling it like: getText("findMe"), when you want getText(findMe)...
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles