T
Tom
I'm trying to figure out how to select one of several pre-defined
arrays based on a value passed to the function. For example:
function doRollup(Instring1) {
Array_1 = new Array (1,2,3);
Array_2 = new Array (4,5,6);
Array_3 = new Array (7,8,9);
var ArrayName = 'Array_' + Instring1;
for(x=0;x<ArrayName .length;x++)
{
// do stuff
}
}
<input type=button value="Test" onClick="doRollup(1)">
I want to be able to choose the appropriate array based on the value
of Instring1. However, in the example above, substituting variable
ArrayName for the actual array name does not work. It's merely a
string that has the same name as the array.
Any suggestions ? Thanks
arrays based on a value passed to the function. For example:
function doRollup(Instring1) {
Array_1 = new Array (1,2,3);
Array_2 = new Array (4,5,6);
Array_3 = new Array (7,8,9);
var ArrayName = 'Array_' + Instring1;
for(x=0;x<ArrayName .length;x++)
{
// do stuff
}
}
<input type=button value="Test" onClick="doRollup(1)">
I want to be able to choose the appropriate array based on the value
of Instring1. However, in the example above, substituting variable
ArrayName for the actual array name does not work. It's merely a
string that has the same name as the array.
Any suggestions ? Thanks