title: Create <option> on the fly with jQuery
body: <p>I'd like to build s on the fly in a  box based on an AJAX response; i.e. if the responseText is 3, I'd like to build 3 options:</p>
  
  <pre><code>&lt;option value="1"&gt;1&lt;/option&gt;
  &lt;option value="2"&gt;2&lt;/option&gt;
  &lt;option value="3"&gt;3&lt;/option&gt;
  </code></pre>
  
  <p>The following piece of code is working:</p>
  
  <pre><code>$("#PAG_PLACEMENT").change(function(){
              $.ajax({
              type: "post",
              url: "untitled.asp",
              data: "iLanguage=1&amp;iPlacement="+$("#PAG_PLACEMENT").val(),
              success: function(responseText){
                      //alert(parseInt(responseText));
                      opts = parseInt(responseText);
                              var routeSelect = $("#PAG_POSITION").get(0);
                              routeSelect.options.length = 0; //reset to zero length
                              for(var i = 0; i &lt; opts; ++i) {
                              routeSelect.options[i] = new Option(i+1,i+1);
                              }
                      }
              });
      });
  </code></pre>
  
  <p>but I'd like to "jQueryfy" the part:</p>
  
  <pre><code>var routeSelect = $("#PAG_POSITION").get(0);
      routeSelect.options.length = 0; //reset to zero length
      for(var i = 0; i &lt; opts; ++i) {
      routeSelect.options[i] = new Option(i+1,i+1);
  }
  </code></pre>
  
  <p>More, sometimes the responseText is null (the page is blank) and parsing it gives of course a "NaN": well, in this case I'd like to fill the  with a simple:</p>
  
  <pre><code>&lt;option value="0"&gt;0&lt;value&gt;
  </code></pre>
  
  <p>I'm a JS newbie and don't know how to do this...
  Please, can you help?</p>