Why is this function not executing on page load? (How to create HTML option using JavaScript at page load)
<p>I want to fill a dropdown list and I've written the following code: </p>

<pre><code>&lt;script language="JavaScript1.2"&gt;
window.onload = fillDropDown();

function fillDropDown() {

        var ddl = document.getElementById("dia");
    var theOption = new Option;
    var x;
    var i;

    for(i = 1; i &lt; 32; i++) {
        x = i + 1;
        theOption.text = x;
        theOption.value = x;
        ddl.options[i] = theOption;
    }


}

&lt;/script&gt;
   &lt;body&gt;
    &lt;form&gt;
           &lt;select id=dia&gt;&lt;/select&gt;
    &lt;/form&gt;
   &lt;body&gt;
</code></pre>

<p>It isn't working, any idea why? </p>
