View Full Version : switching variable names dynamically

tyler jones
07-08-2002, 07:57 PM
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.

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


tyler jones
07-08-2002, 08:13 PM
Nevermind.... eval() to the rescue:)