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.
<table align="center">
<tr>
<td>
<b>Select Year ::</b>
</td>
<td>
<select id='getYear' onchange="yearChanged(this.value);">
</select>
</td>
</tr>
</table>
and the corresponding javascript code that populates the values in it is as follows
$(document).ready(function() {
var d = new Date();
var year = d.getFullYear();
var select = document.getElementById("getYear");
for(var i=0 ; i < 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);
});
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?