function fillCategory(){ // this function is used to fill the category list on load addOption(document.drop_list.Category, 'Boston', 'Boston');addOption(document.drop_list.Category, 'Los Angeles', 'Los Angeles');} // end of JS function function SelectSubCat(){ // ON or after selection of category this function will work removeAllOptions(document.drop_list.SubCat); addOption(document.drop_list.SubCat, "", "Select Area", ""); // Collect all element of subcategory for various cat_id if(document.drop_list.Category.value == 'Boston'){addOption(document.drop_list.SubCat,'Chestnut Hill', 'Chestnut Hill (1)');}if(document.drop_list.Category.value == 'Los Angeles'){addOption(document.drop_list.SubCat,'Alhambra', 'Alhambra (1)');addOption(document.drop_list.SubCat,'Culver City', 'Culver City (1)');addOption(document.drop_list.SubCat,'Eagle Rock', 'Eagle Rock (1)');addOption(document.drop_list.SubCat,'Los Angeles', 'Los Angeles (1)');addOption(document.drop_list.SubCat,'Los Angeles, ', 'Los Angeles, (1)');addOption(document.drop_list.SubCat,'South Pasadena', 'South Pasadena (4)');} } ////////////////// function removeAllOptions(selectbox) { var i; for(i=selectbox.options.length-1;i>=0;i--) { //selectbox.options.remove(i); selectbox.remove(i); } } function addOption(selectbox, value, text ) { var optn = document.createElement("OPTION"); optn.text = text; optn.value = value; selectbox.options.add(optn); }