title: Add item to dropdown list in HTML using JavaScript
body: <p>I have this JavaScript+HTML to populate a dropdown menu but it is not working, am i doing anything wrong? Note I want the drop down menu to be filled on page Load</p>
  <pre><code>    &lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;head&gt;
      &lt;script&gt;
      function addList(){
      var select = document.getElementById(&quot;year&quot;);
      for(var i = 2011; i &gt;= 1900; --i) {
      var option = document.createElement('option');
      option.text = option.value = i;
      select.add(option, 0);
        }
       }
      &lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
  
         &lt;select id=&quot;year&quot; name=&quot;year&quot;&gt;&lt;/select&gt;
        
      &lt;/body&gt;
      &lt;/html&gt; 
  </code></pre>