title: How to keep a particular value selected in select tag
body: <p>Below is my drop down in JSP where in I have to show the year values and these year values are populated when the document is ready, for which I have written JavaScript code.</p>
  
  <pre><code>&lt;table align="center"&gt;
      &lt;tr&gt;
          &lt;td&gt;
              &lt;b&gt;Select Year ::&lt;/b&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;select id='getYear' onchange="yearChanged(this.value);"&gt;
  
              &lt;/select&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
       &lt;/table&gt;
  </code></pre>
  
  <p>and the corresponding javascript code that populates the values in it is as follows</p>
  
  <pre><code>$(document).ready(function() {
      var d = new Date();
      var year = d.getFullYear();
  
      var select = document.getElementById("getYear");
  
      for(var i=0 ; i &lt; 8; i++){
  
          var displayPast10Year = (parseInt(year)) - i;
          var option = document.createElement('option');
          option.text = option.value = displayPast10Year;  
          select.add(option, 0);
  
       }
  
  
      select.valueOf(year);
      $("#getYear").val(year); 
      yearChanged(year);
  
  });
  </code></pre>
  
  <p>My requirement is that the drop down (i.e select tag) shows the year value as 2016 when the document is ready. How do I do so?</p>