Web Analytics Made Easy -
StatCounter Using A Variable Value to Declare A Variable? - CodingForum

Announcement

Collapse
No announcement yet.

Using A Variable Value to Declare A Variable?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using A Variable Value to Declare A Variable?

    Say the variable menu contains the value "menu1" and I want to declare a variable called menu1_status. I want to do something like:

    var eval(menu + "_status") = 1;

    Except that doesn't work, even without the var part (with var it complains about syntax). Hopefully you understand what I'm trying to accomplish! Any suggestions are appreciated. Thanks in advance.

  • #2
    window[menu+ '_status']=1;
    liorean <[[email protected]]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

    Comment


    • #3
      Wow, thank you, sir.

      Comment

      Working...
      X