| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Easy function for numeric or date drop down lists asp
Below is an example of how to quickly construct a day/month/year date dropdown.
Te function will automatically decrease the numbers if the BeginCount > EndCount Code:
<%
Sub DropDownDate(BeginCount,EndCount)
dim iCount
if BeginCount > EndCount then
iCount = BeginCount + 1
EndCount = cint(EndCount)
While iCount >= EndCount
%>
<option value="<%=iCount%>"><%=iCount%></option>
<%
iCount = iCount - 1
Wend
else
iCount = BeginCount - 1
EndCount = cint(EndCount)
While iCount <= EndCount
%>
<option value="<%=iCount%>"><%=iCount%></option>
<%
iCount = iCount + 1
Wend
end if
end sub
'=========================================
'Day
'=========================================
response.write("<select name=""""day"""">")
response.write("<option value="""""""">Select day</option")
Call DropDownDate(1,31)
response.write("</select>")
'=========================================
'Month
'=========================================
response.write("<select name=""""month"""">")
response.write("<option value="""""""">Select month</option")
Call DropDownDate(1,12)
response.write("</select>")
'=========================================
'Year
'=========================================
response.write("<select name=""""year"""">")
response.write("<option value="""""""">Select year</option")
Call DropDownDate(2006,1943)
response.write("</select>")
%>
|
|
#2
|
|||||
|
|||||
|
You have an HTML error in your code
Code:
response.write("<option value="""""""">Select day</option")
You are missing the closing > from the options If you add this in you will notice that the script does not work correctly. Looping starts from 0 instead of 1. Also, you could trim down the coding e.g. asp Code:
__________________
CyberTechHelp Last edited by degsy : January 16th, 2007 at 06:24 AM. |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Easy function for numeric or date drop down lists asp |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|