Here I have created simple dropdown list that shows months for every year.
U can initialize the year from where u want to start.
I have started from year "1999".
Similarly,
U can use Following example to display list of animals in certain category OR List Of items in certain Product,Etc.
Here is the Code :
Explanation :
Step 1 : Declare and initialize variables.
Initialize Start year whatever u want and EndYear.
Here I have taken started from 1999 to current year.
Step 2 : Declare and Create array for months.
Step 3 : Start Select list with optiongroup and with first value "--Select--"
Step 4 : Loop through Start Year and End Year
Check the year already displayed or not. if not then display else skip and display months.
Display years in "optgroup"
Step 5 : Loop Through Array of months and display months
Step 6 : End Inner for loop and assign the year in a variable
Step 7 : End Outer for loop
U can initialize the year from where u want to start.
I have started from year "1999".
Similarly,
U can use Following example to display list of animals in certain category OR List Of items in certain Product,Etc.
Here is the Code :
Code:
<%
Dim StartYear,TillYear,StrCheck
StartYear = 1999
TillYear = Year(Date())
StrCheck = ""
Dim MonthsArr(11)
MonthsArr(0) = "Jan"
MonthsArr(1) = "Feb"
MonthsArr(2) = "Mar"
MonthsArr(3) = "Apr"
MonthsArr(4) = "May"
MonthsArr(5) = "Jun"
MonthsArr(6) = "Jul"
MonthsArr(7) = "Aug"
MonthsArr(8) = "Sep"
MonthsArr(9) = "Oct"
MonthsArr(10) = "Nov"
MonthsArr(11) = "Dec"
Dim i,StrValue
%>
<select name="CmbMonYear">
<option value="0">--Select--</option>
<%
For Yrs = StartYear To TillYear
If StrCheck <> Yrs Then
%>
<optgroup label="<%=Yrs%>">
<%End If
For i = 0 To Ubound(MonthsArr)
%>
<option value="<%=MonthsArr(i)%>"<%If MonthsArr(i) = Request.Form("CmbMonYear") Then Response.Write("Selected") End If%>>
<%=MonthsArr(i)%></option>
<% Next
StrCheck = Yrs
Next
%>
</optgroup>
</select>
Step 1 : Declare and initialize variables.
Initialize Start year whatever u want and EndYear.
Here I have taken started from 1999 to current year.
Code:
<%
Dim StartYear,TillYear,StrCheck
StartYear = 1999
TillYear = Year(Date())
StrCheck = ""
%>
Code:
<% Dim MonthsArr(11) MonthsArr(0) = "Jan" MonthsArr(1) = "Feb" MonthsArr(2) = "Mar" MonthsArr(3) = "Apr" MonthsArr(4) = "May" MonthsArr(5) = "Jun" MonthsArr(6) = "Jul" MonthsArr(7) = "Aug" MonthsArr(8) = "Sep" MonthsArr(9) = "Oct" MonthsArr(10) = "Nov" MonthsArr(11) = "Dec" Dim i,StrValue %>
Code:
<select name="CmbMonYear"> <option value="0">--Select--</option>
Check the year already displayed or not. if not then display else skip and display months.
Display years in "optgroup"
Code:
<% For Yrs = StartYear To TillYear If StrCheck <> Yrs Then %> <optgroup label="<%=Yrs%>"> <%End If%>
Code:
<% For i = 0 To Ubound(MonthsArr)
%>
<option value="<%=MonthsArr(i)%>"<%If MonthsArr(i) = Request.Form("CmbMonYear") Then Response.Write("Selected") End If%>>
<%=MonthsArr(i)%></option>
Code:
<% Next StrCheck = Yrs %>
Code:
<%Next %> </optgroup> </select>