Forum Moderators: open
Problematic js is as follows:
function populatePa()
{
if (!optionTest) return;
var box = document.forms['filters'].first;
var number = box.options[box.selectedIndex].value;
if (!number ¦¦ number==0) return;
var list = storeP[number];
var box = document.forms['filters'].fourth;
box.options.length = 0;
for(i=0;list.length;i+=2)
{
box.options[i/2] = new Option(list[i],list[i+1]);
}
}
JS Arrays (to populate "fourth" select list):
var storeP = new Array();
storeP['7'] = new Array(
'No Products available','');
storeP['16'] = new Array(
'No Products available','');
storeP['14'] = new Array(
'No Products available','');
storeP['21369'] = new Array(
'-- Products -- ','',
'Hyundai ImageQuest 32" LCD Screen','1');
storeP['3'] = new Array(
'No Products available','');
storeP['10'] = new Array(
'No Products available','');
storeP['8'] = new Array(
'-- Products -- ','',
'Dell Latitude C610 Laptop','3',
'HP Omnibook 6000 Laptop','7',
'Packard Bell Easynote R1 000 Laptop','6',
'Packard Bell Easynote W1 801 Laptop','5');
storeP['11'] = new Array(
'No Products available','');
storeP['9'] = new Array(
'No Products available','');
storeP['4'] = new Array(
'No Products available','');
If you have access to view the area in question, when choosing from the sections select list the script hangs populating the products select list, it will return the correct array but then appears to return and infinate number of undefined select option elements, this takes place on the 2 other seperate populate functions used (not listed here) named:
populatePa() < Listed above, populates according to first option
populatePb() < Populates according to second option
populatePc() < Populates according to third option
Origonal script was sourced from here to populate a secondary select list according to the option select in the first list, modified to handle up to three select lists (chaging the next level according to previous selection). This final piece is to display products according to section chosen (category, subcategory or subfilter/tree).
Please leave a sticky and i will give you more info.
TIA
for(i=0;[b]list.length;[/b]i+=2) That second bit should be the condition under which the loop ends, which is to say, something like
for(i=0;[b]i<list.length[/b];i+=2) . As far as getting undefined results, could it have anything to do with these guys:
storeP['7'] = new Array(
'No Products available',''); ? I don't think you want quotes around the size of the array. Hope some of that helps...