Web Analytics Made Easy -
StatCounter switching variable names dynamically - CodingForum

Announcement

Collapse
No announcement yet.

switching variable names dynamically

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    Nevermind.... eval() to the rescue

    Comment

    Working...
    X