I have an ASP drop down list called and I need to load numbers 1 to 20 with 1 being selected as default. How to do this with javascript? I have a sample code but the drop down is not loading. Am I missing something?
<script>
function quantitydropdown() {
var ddl = document.getElementById('quantitydropdownid').getElementsByTagName("select")[0];
for (var i = 1; i <= 100; i++) {
var theOption = new Option;
theOption.text = i;
theOption.value = i;
ddl.options[i] = theOption;
}
}
</script>
<select id="quantitydropdownid" onchange="javascript:quantitydropdown();" runat="server" style="width: 200px;"></select>