Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 15th, 2007, 05:11 PM
urbanmike urbanmike is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Sydney, Australia
Posts: 32 urbanmike User rank is Corporal (100 - 500 Reputation Level)urbanmike User rank is Corporal (100 - 500 Reputation Level)urbanmike User rank is Corporal (100 - 500 Reputation Level)urbanmike User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 49 m 44 sec
Reputation Power: 3
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>")
%>

Reply With Quote
  #2  
Old January 16th, 2007, 06:21 AM
degsy degsy is offline
Contributing User
ASP Free God 2nd Plane (6000 - 6499 posts)
 
Join Date: Aug 2005
Location: North East, UK
Posts: 6,191 degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level)degsy User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 19 h 41 m 52 sec
Reputation Power: 121
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:
Original - asp Code
  1. Sub DropDownDate(Interval,BeginCount,EndCount,Indentat  ion)
  2.     i=0 : s=1
  3.     If IsNumeric(Indentation) Then i = CInt(Indentation)
  4.     If BeginCount > EndCount Then s = -1
  5.  
  6.     Response.Write Space(i) & "<select name=""" & Interval & """>" & vbCrlf
  7.     Response.Write Space(i+2) & "<option>Select " & Interval & "</option>" & vbCrlf
  8.     For iCount=BeginCount To EndCount Step s
  9.         Response.Write Space(i+2) & "<option value=""" & iCount & """>" & iCount & "</option>" & vbCrlf
  10.     Next
  11.     Response.Write Space(i) & "</select>" & vbCrlf
  12. End Sub
  13.  
  14. Call DropDownDate("Day",1,31,0)
  15. Call DropDownDate("Month",1,12,0)
  16. Call DropDownDate("Year",2006,1943,0)
__________________
CyberTechHelp

Last edited by degsy : January 16th, 2007 at 06:24 AM.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Easy function for numeric or date drop down lists asp


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway