...

View Full Version : switching variable names dynamically



tyler jones
07-08-2002, 06: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
</select>

Thanks.

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum