I am trying to get the values to a select list for subcategories on the basis on what is chosen in categories select list. It doesn't seem to work on IE. Can anyone suggest the problem?
In the php file I have
<body onload="setSubcategories(default_value);">
In the js file I have something like
subcategories = new Array();
subcategories['Lifestyle'] = ['All',
'Beauty (SHC)',
'Skin Care',
'Hair Care',
'Oral Care',
'Cosmetics',
'Footwear',
'Jewelry',
'Male Styling',
'Women Hygiene',
'Womens magazines',
'Apparels',
' Fashion (AFA)',
'Spa',
'Accessories'
];
subcategories['Automobiles'] = ['All',
'Automobiles (C&B)',
'Cars',
'Bikes',
'Car Magazine',
'Bikes Magazine',
'Accessories'
];
subcategories['FoodandBeverage'] = ['All',
'Snacking',
'Confectionary',
'Beverages',
'Generic F&B',
'Restaurant Review',
'Food Reviews',
'Wines & Vineyards'
];
function setSubcategories(default_value){
default_value = (typeof default_value == 'undefined') ?
'All' : default_value;
var elem = document.getElementById('id-category');
if(elem == null){return false;}
var category = elem.value;
var subelem = document.getElementById('id-subcategory');
var html = "";
var subcategoriesArr = subcategories[category];
for(var i=0; i < subcategoriesArr.length; i++){
var selected = subcategoriesArr[i] == default_value ? " selected" : "";
html += '<option' + selected + '>' + subcategoriesArr[i] + '</option>\n';
}
subelem.innerHTML = html;
}