I am using a script to populate dropdown menus:
<SCRIPT LANGUAGE="JavaScript">
function SelectSubCat(){
// ON selection of category this function will work
removeAllOptions(document.main.SubCat);
if(document.main.Category.value == '1'){
addOption(document.main.SubGift,"option 1", "option 1");
addOption(document.main.SubGift,"option 2", "option 2");
}
if(document.main.Category.value == '3'){
addOption(document.main.SubGift,"option 1", "option 1");
addOption(document.main.SubGift,"option 2", "toption 2");
}
if(document.main.Category.value == '4'){
addOption(document.main.SubGift,"option 1", "option 1");
}
}
//////////////////
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);
}
</script>
How can I modify this script so that the first option is automatically selected from my second dropdown menu?
Many thanks and merry Christmas!
<SCRIPT LANGUAGE="JavaScript">
function SelectSubCat(){
// ON selection of category this function will work
removeAllOptions(document.main.SubCat);
if(document.main.Category.value == '1'){
addOption(document.main.SubGift,"option 1", "option 1");
addOption(document.main.SubGift,"option 2", "option 2");
}
if(document.main.Category.value == '3'){
addOption(document.main.SubGift,"option 1", "option 1");
addOption(document.main.SubGift,"option 2", "toption 2");
}
if(document.main.Category.value == '4'){
addOption(document.main.SubGift,"option 1", "option 1");
}
}
//////////////////
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);
}
</script>
How can I modify this script so that the first option is automatically selected from my second dropdown menu?
Many thanks and merry Christmas!