Dynamically Populating a Select Box
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
function fillselect(trval, targetC)
{
var select = document.getElementById(targetC);
removeallsel(select);
var inputarr = new Array()
inputarr[0] = "1"
inputarr[1] = "2"
for(var i = 0; i < inputarr.length; i++) {
var option = document.createElement('option');
option.appendChild(document.createTextNode(trval + inputarr[i]));
select.appendChild(option);
}
}
function removeallsel(sel)
{
for(var i=sel.options.length;i>=0;i--){
sel.options[i]=null;
}
}
</script>
<title>e</title>
</head>
<body>
Select first option:
<select id="fname" onchange="fillselect(this.value, 'fname1')">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c </option>
</select>
<select id="fname1">
</select>
</body>
</html>