Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    47
    Thanks
    1
    Thanked 0 Times in 0 Posts

    switching variable names dynamically

    I have a number of arrays in my script and a drop down menu for the person to choose an item. Based off of which item they choose, I need to loop through the array that has the same name as the value of the option they selected. So, for instance, I might have something like this.
    Code:
    function dowhatever(sBox)
    {
      var ar1 = new Array(1,2,3);
      var ar2 = new Array(2,3,4);
      var selectedArray = sBox.options[sBox.selectedIndex].value;
      // how do I loop through the selected array here?
    }
    
    <select onChange = "dowhatever(this);">
    <option value="ar1">ar1</option>
    <option value="ar2">ar2</option
    </select>
    Thanks.

  • #2
    New Coder
    Join Date
    Jul 2002
    Posts
    47
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Nevermind.... eval() to the rescue


  •  

    Posting Permissions

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