So I want to add a dropdown in my form that will display numbers from 1 to 999 . I have tried to do it using JS but it doesn't work Here is what I have tried so far :
<html>
<head>
<script>
window.onload = fillDropDown();
function fillDropDown() {
var ddl = document.getElementById( 'myDropdown' );
var theOption = new Option;
var x;
var i;
for(i = 0; i < 999; i++) {
x = i + 1;
theOption.text = x;
theOption.value = x;
ddl.options[i] = theOption;
}
}
</script>
</head>
<body>
<form id="myForm">
<select id="myDropdown"></select>
</form>
</body>
But it doesn't work . Here is a jsfiddle example http://jsfiddle.net/j3nLxptn/