Hey,
I have 2 select menus, and depending on what is selected in the first one, the values change in the second one. This all works fine, but if someone changes the first menu to the default option, I want to clear all options from the second menu.
The function is as follows:
The code in the else statement is supposed to clear the values of the second drop down, but no matter what, it always leaves the even elements in the list. Any ideas how I could fix this?
A working example of the code can be seen here:
Thanks!
I have 2 select menus, and depending on what is selected in the first one, the values change in the second one. This all works fine, but if someone changes the first menu to the default option, I want to clear all options from the second menu.
The function is as follows:
Code:
function updateResorts()
{
var dest = document.BBForm.Country.options[document.BBForm.Country.selectedIndex].value;
if (IsNumeric(dest))
{
var btDestinations = new Array();
btDestinations[1] = new Array();
btDestinations[1][1] = "Benidorm 1";
btDestinations[1][2] = "Benidorm 2";
btDestinations[1][3] = "Benidorm 3";
btDestinations[1][4] = "Benidorm 4";
btDestinations[1][5] = "Benidorm 5";
btDestinations[1][6] = "Benidorm 6";
btDestinations[1][7] = "Benidorm 7";
btDestinations[1][8] = "Benidorm 8";
btDestinations[2] = new Array();
btDestinations[2][1] = "Benalmadena, 1";
btDestinations[2][2] = "Marbella, 2";
btDestinations[2][3] = "Torremolinos, 3";
btDestinations[3] = new Array();
btDestinations[3][1] = "Caleta de Fuste, 1";
btDestinations[3][2] = "Corralejo, 2";
var ccDest = btDestinations[dest].length;
document.BBForm.Resort.options[1] = null;
document.BBForm.Resort.options[0] = new Option("Please Select Resort","");
for(i = 1; i < ccDest; i++)
{
var dtValues=btDestinations[dest][i].split(", ");
document.BBForm.Resort.options[i] = new Option(dtValues[0],dtValues[1]);
}
}
else
{
document.BBForm.Resort.selectedIndex = 0;
var killOptions = document.BBForm.Resort.options.length;
for (j=1;j<killOptions;j++)
{
document.BBForm.Resort.remove(j);
}
}
}
The code in the else statement is supposed to clear the values of the second drop down, but no matter what, it always leaves the even elements in the list. Any ideas how I could fix this?
A working example of the code can be seen here:
Thanks!