title: Load asp dropdown list with numbers 1 - 20
body: <p>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?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;script&gt;
      function quantitydropdown() {
          var ddl = document.getElementById('quantitydropdownid').getElementsByTagName("select")[0];
  
          for (var i = 1; i &lt;= 100; i++) {
              var theOption = new Option;
              theOption.text = i;
              theOption.value = i;
              ddl.options[i] = theOption;
          }
      }
  &lt;/script&gt;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;select id="quantitydropdownid" onchange="javascript:quantitydropdown();" runat="server" style="width: 200px;"&gt;&lt;/select&gt;</code></pre>
  </div>
  </div>
  </p>