I want to regenerate List2 (selSortt) everytime the user changes the selection in List1 (selQueryType). In its original state, List2 is blank. Both lists are part of a larger HTML input document. List1 has 4 options, so in the end there will be 4 ifs - actually a switch. List 2 is generated from a predefined array (listvalues), NOT from List1 (see code).
Function QueryTypeChg() is fired by onchange List1 - I checked with an alert, it is fired. The problem seems to be in the for cycle, when trying to generate the new options of List2. No options are added to List2 - it remains blank, as it is originally.
function QueryTypeChg()
{
var selIndex = document.getElementById("selQueryType").selectedIndex;
var objSel = document.getElementById("selSortt");
var i = 0;
while (objSel.length > 0)
{
objSel.remove(0);
}
if (selIndex == 0)
{
var listvalues = ["Species", "Region, area", "Anthesis", "Vulnerability"];
for (i = 0; i < options.length; i++)
{
var option = document.createElement("option");
option.text = listvalues[i];
option.value = i;
// alert("option.text is " + option.text);
objSel.add(option);
}
}
}