I have a monthly report and the user needs to select the report they want according to the month and year. The user will generally be wanting to view the previous month's report but they might want an older one. The first report generated was for October 2006 but when 2007 comes real soon I don't want to hard code the year 2007 in the list. I need it to generate a new year every year starting with 2006.
Here is what I have for defaulting the Month's drop down list to the previous month:
But I need to add the code to generate the current year (if it's not 2006) and include all years from the current year to 2006 without hardcoding it like I did above. In other words, in 2008 it will list 2006, 2007 & 2008.
Thanks.
Here is what I have for defaulting the Month's drop down list to the previous month:
Code:
<script language="JavaScript">
<!--
function initdt(mf) {
var t = new Date;
mf.month.value = t.getMonth();
mf.year.value = t.getFullYear();
}
//-->
</script>
<body onload="initdt(document.DateList);">
<select name="month" size="1">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select size="1" name="year">
<option value="2006">2006</option>
<option value="2007">2007</option>
</select>
But I need to add the code to generate the current year (if it's not 2006) and include all years from the current year to 2006 without hardcoding it like I did above. In other words, in 2008 it will list 2006, 2007 & 2008.
Thanks.