thegentleman
IS-IT--Management
Hi,
I am creating a function that requires large arrays of products split into 4 levels:
ar[0] = new Array();
ar[0][0] = new makeOption("NONE","0"
ar[1] = new Array();
ar[1][0] = new makeOption("NONE","0"
ar[2] = new Array();
ar[2][0] = new makeOption("NONE","0"
ar[3] = new Array();
ar[3][0] = new makeOption("NONE","0"
ar[3][1] = new makeOption("James Bond","11"
ar[3][1][0] = new makeOption("NONE","0"
ar[3][1][1] = new makeOption("40th Anniversary","18"
ar[3][1][1][0] = new makeOption("NONE","0"
ar[3][1][2] = new makeOption("Anniversary Expansion","19"
ar[3][1][2][0] = new makeOption("NONE","0"
I can assign the length of the first level arrays to a variable without any problem using the following code:
var curAr = ar[3].length
But I cannot seem to get the length of the second level array with the following:
var curAr = ar[3][1].length
I do not get an error but in this scenario curAr is always 0 or Null. Here is the full function:
-----------------------------------------------
function relate_s1(form) {
var options = form.cid_s2.options;
for (var i = options.length - 1; i > 0; i--) {
options = null;
}
var curAr = ar[form.cid.selectedIndex][form.cid_s1.selectedIndex];
for (var j = 0; j < curAr.length; j++) {
options[j] = new Option(curAr[j].text,curAr[j].value);
}
options[0].selected = true;
}
-------------------------------
Any ideas?
~tg
I am creating a function that requires large arrays of products split into 4 levels:
ar[0] = new Array();
ar[0][0] = new makeOption("NONE","0"
ar[1] = new Array();
ar[1][0] = new makeOption("NONE","0"
ar[2] = new Array();
ar[2][0] = new makeOption("NONE","0"
ar[3] = new Array();
ar[3][0] = new makeOption("NONE","0"
ar[3][1] = new makeOption("James Bond","11"
ar[3][1][0] = new makeOption("NONE","0"
ar[3][1][1] = new makeOption("40th Anniversary","18"
ar[3][1][1][0] = new makeOption("NONE","0"
ar[3][1][2] = new makeOption("Anniversary Expansion","19"
ar[3][1][2][0] = new makeOption("NONE","0"
I can assign the length of the first level arrays to a variable without any problem using the following code:
var curAr = ar[3].length
But I cannot seem to get the length of the second level array with the following:
var curAr = ar[3][1].length
I do not get an error but in this scenario curAr is always 0 or Null. Here is the full function:
-----------------------------------------------
function relate_s1(form) {
var options = form.cid_s2.options;
for (var i = options.length - 1; i > 0; i--) {
options = null;
}
var curAr = ar[form.cid.selectedIndex][form.cid_s1.selectedIndex];
for (var j = 0; j < curAr.length; j++) {
options[j] = new Option(curAr[j].text,curAr[j].value);
}
options[0].selected = true;
}
-------------------------------
Any ideas?
~tg