0

How would I set up an array to write out the year in a drop down list from current year and back 50 years?

What I have now:

<select name="Year">
<option selected>--Year--</option> 
<% If Month(Now) = 12 Then %>
<option value="<%=Year(Now) +1 %>"><%=Year(Now) +1 %></option>                
<% End If %>                   
<option value="<%=Year(Now)%>"><%=Year(Now)%></option>

1 Answer 1

0
<%
Const cNumberOfYears = 50
Dim nCount
Dim nYear: nYear = Year(Now)
%>
<select name="Year">
<%
For nCount = 0 To cNumberOfYears - 1
    Response.write "<option value=""" & (nYear - nCount) & """>" & (nYear - nCount) & "</option>"
Next
%>
</select>

update: just realized it can be done much simpler, saving you a variable ;-)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.