I have the following which gives a acending order of the years 1920 -1986
How would I reverse this to decending; or 1986 - 1920
<form name="Escc" method="POST" action=" ">
<%
String passedDobYr = (String) request.getParameter("dobYr");
if (passedDobYr==null) passedDobYr="";
int start = 82; // when does the years start
int end = 16; // and when do they end
String[] years = new String[start-end+1];
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.add(java.util.Calendar.YEAR,-start);
for (int i=0;i<start-end+1;i++) {
years[i]= String.valueOf(cal.get(java.util.Calendar.YEAR));
cal.add(java.util.Calendar.YEAR,1);
}
// Here we have an array of years from 2002-16 to 2002-82
//needs to start with 1986
// next year it would be 2003-60 to 2003-16
// and end with 1920
%>
<select name="dobYr" >
<OPTION >Year
<%
String sel = "";
for (int i=0;i<years.length;i++) {
if (years[i].equals(passedDobYr)) sel = "selected";
else sel = "";%>
<option value="<%= years[i] %>"
<%= sel %> >
<%= years[i] %>
</option>
<%}%>
</select>
Thanks