Reputation: 11338
Is there a way to remove the first options from this script:
http://javascript.internet.com/navigation/connected-comboxes.html
I want to remove the [ Type ] and [ Style ] options from the list and display other options only...
Can anyone please help?
Upvotes: 0
Views: 397
Reputation: 540
In addition to what is already suggested do some tweaks in code, set 1 =0 and if you also want to remove first empty option from second combo use j = 0
================================
function init(sel_type, sel_style){
for(i = 0; i <= TypeArray.length; i++){
document.product.id_type.options[i] = new Option(TypeArray[i].type, TypeArray[i].id);
if(TypeArray[i].id == sel_type)
document.product.id_type.options[i].selected = true;
}
OnChange(sel_style);
}
function OnChange(sel_style){
sel_type_index = document.product.id_type.selectedIndex;
sel_type_value = parseInt(document.product.id_type[sel_type_index].value);
for(i = document.product.id_style.length - 1; i > 0; i--)
document.product.id_style.options[i] = null;
j=1;
for(i = 0; i <= StyleArray.length; i++){
if(StyleArray[i].id_type == sel_type_value){
document.product.id_style.options[j] = new Option(StyleArray[i].style, StyleArray[i].id);
if(StyleArray[i].id == sel_style) document.product.id_style.options[j].selected = true;
j++;
}
}
}
Upvotes: 0
Reputation: 51062
Remove the following lines:
document.product.id_type.options[0] = new Option("[ Type ]");
document.product.id_style.options[0] = new Option("[ Style ]");
Upvotes: 1