title: add option value of the select box dynamically using javascript
body: <p>I want to populate the year in a select javascript. I did the following code.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;script type="text/javascript"&gt;         
          $(document).ready(function(){   
              var cur_year=new Date().getFullYear();
              var obj=document.getElementById("yr");  
              alert(obj);         
              for (var i = 2000; i &lt;= 2020; i++)     {                
                  opt = document.createElement("option");
                  opt.appendChild(document.createTextNode(value));
                  opt.selected = selected;
                  opt.value = i;
                  opt.text=i;
                  obj.appendChild(opt);
              }
          });
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;select id="yr"&gt;
  &lt;option&gt;year&lt;/option&gt;
  &lt;/select&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I don't know what is wrong in this. I want to populate the year and want to select the current year in the select box when the user opens the browser. Any one can help? please!</p>