DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
DYNAMIC DROP DOWN BOX TO LIST YEARS
Think about this. You have a school or business, and want a user to input the year they worked there or attend classes. I have scripted a simple solution to allow a programmer to setup a start year and the script will fill in the years. For example: If my business started in 1978 and I wanted to put a form out on the web that would be there for surveys. The form would be used year after year. I would have to remember to go back in the form each year and add the new year, for example 2000, 2001. This script will automatically make the updates for you. It seems like a small script, but think of how many hours are spent updating pages, and think of the benefits of never updating drop downs years again.
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6313
<%
' DYNAMIC DROP DOWN BOX TO LIST YEARS
' PROGRAMMER: Anthony J. Biondo Jr.
' Website: http://www.chernoblechicken.com
'
' Description: Think about this. You hav
' e a school or business, and want a user
' to input the year they worked there or a
' ttend classes.
' I have scripted a simple solution to a
' llow a programmer to setup a start year
' and the script will fill in the years. F
' or example: If my
' business started in 1978 and I wanted
' to put a form out on the web that would
' be there for surveys. The form would be
' used year after year.
' I would have to remember to go back in
' the form each year and add the new year,
' for example 2000, 2001. This script will
' automatically make
' the updates for you. It seems like a s
' mall script, but think of how many hours
' are spent updating pages, and think of t
' he benefits of never
' updating drop downs years again.
'
' SETUP VARIABLES
myStartYear = 1978 ' YEAR To START COUNT FROM
myYearToday = year(now()) ' THIS YEAR CALCULATED
respyear = myStartYear ' SETTING EQUAL To TEMP VARIABLE SO WE DON'T TRASH OUR STARTING VALUE
' CALCULATE THE DIFFERENCE IN YEARS AND
' SET TO A TEMP VARIABLE
yearDiff = int(myYearToday) - myStartYear
response.write "<Select name='myYear'>"
response.write "<OPTION value='0' selected>----</OPTION>"
For i=0 To yearDiff
response.write "<OPTION value='"&respYear&"'>"&respYear&"</OPTION>"
respYear = respYear + 1
next
response.write "</Select>"
%>





