Select Current Year?

1. Senior Member
Join Date
Dec 1969
Posts
106

Select Current Year?

Maybe I am doing this wrong, but some some reason this is not working. I am trying to get the drop down box to select the current year from a 5 year span. Any help would be appreciated.<BR><BR>&#060;% <BR>Dim Y,YearArray <BR>Redim YearArray(5) <BR>YearArray(1) = "2001" <BR>YearArray(2) = "2002" <BR>YearArray(3) = "2003" <BR>YearArray(4) = "2004" <BR>YearArray(5) = "2005" <BR>%&#062;<BR>&#060;select name="Year"&#062;<BR>&#060;%<BR>For Y = 1 To 5<BR>%&#062;<BR>&#060;option value="&#060;%=YearArray(Y)%&#062;" &#060;%If YearArray(Y)=Year(Now) Then Response.Write "SELECTED"%&#062;&#062;&#060;%=YearArray(Y)%&#062; &#060;/option&#062; &#060;%=Year(Now)%&#062;=&#060;%=YearArray(Y)%&#06 2;<BR>&#060;%Next %&#062;<BR>&#060;select&#062;

2. Senior Member
Join Date
Dec 1969
Posts
96,118

Why so complex?

&#060;%<BR>For yr = 2001 To 2005<BR> If yr = Year(Now) Then sel = " SELECTED" Else sel=""<BR>%&#062;<BR> &#060;OPTION &#060;%=sel%&#062; &#062;&#060;%= yr %&#062;&#060;/OPTION&#062;<BR>&#060;%<BR>Next<BR>%&#062;<BR><BR> What was the point of this code:<BR> &#060;%=Year(Now)%&#062;=&#060;%=YearArray(Y)%&#06 2;<BR>in your version??? You can&#039;t *have* ANYTHING "in between" &#060;OPTION&#062;s in a &#060;SELECT&#062; list.<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
106

RE: Why so complex?

Whoops..I accidentally left that part in there...I was try to view the source to see if they were coming out as equal. Thanks for the advice Bill!

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•