Code:
<html>
<head>
<script type="text/javascript">
function showlist() {
var listval=document.getElementById("chooseboxtoshow").value;
if (listval=="Opt1") {
document.getElementById("two").style.display="none";
document.getElementById("one").style.display="block";
}
if (listval=="Opt2") {
document.getElementById("one").style.display = "none";
document.getElementById("two").style.display = "block";
}
}
</script>
</head>
<body>
<select id="chooseboxtoshow">
<option value="Opt1">Option 1</option>
<option value="Opt2">Option 2</option>
</select><br /><br />
<div id = "one" style="display:none">
<select id = "firstsel" class="a">
<option value="1a">Option 1a</option>
<option value="1b">Option 2a</option>
</select>
<br />
</div>
<div id = "two" style="display:none">
<select id="secondsel" class="a">
<option value="2a">Option 1b</option>
<option value="2b">Option 2b</option>
</select>
<br />
</div>
<br><br>
<input type="button" value="Show new list" onclick="showlist()">
</body>
</html>
Rather than using a button you could invoke the script with <select id="chooseboxtoshow" onchange = "showlist()"> so long as you included a default or preliminary option <option value = "">Choose an option...</option> so the user's choice selection causes the change.
Note that the value of an option is the string value (example: Opt1) you specify. The selectedIndex is a
number representing the 0th, 1st, 2nd etc. option in the list.
"Dives sum, si non redo eis quibus debeo. - I am a rich man as long as I do not pay my creditors"