asked on
<script>
var stateObject = {
"India": {"Delhi": ["", ""],"Kerala": ["", ""],"Goa": ["", ""],},
"United States": {"Alabama": [""],"Alaska": [""],"Idaho": [""],},
"Australia": {"South Australia": [""],"Victoria": [""]},
"Canada": {"Alberta": [""],"Columbia": [""]},
}
window.onload = function () {
var countySel = document.getElementById("countySel"),
stateSel = document.getElementById("stateSel")
for (var country in stateObject) {
countySel.options[countySel.options.length] = new Option(country, country);
}
countySel.onchange = function () {
stateSel.length = 1;
if (this.selectedIndex < 1) return;
for (var state in stateObject[this.value]) {
stateSel.options[stateSel.options.length] = new Option(state, state);
}
}
}
</script>