All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Quick Search for:  in language:    
small,snippet,will,generate,drop,down,boxes,a
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 281,486. lines
 Jobs: 101. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login

NEW! LEARNING CENTER
Special educational offers, white papers, webcasts, podcasts

  NEW! Download Rational Performance Tester V8 (download now)
  NEW! Download Rational Functional Tester V8 (download now)
  NEW! Download Rational Service Tester for SOA Quality V8 (download now)
  NEW! Teleconference: Quality In Action - Using Rational Quality Manager with Functional, Performance and Web Service Testing Products (download now)
  NEW! Introducing IBM Rational AppScan Developer Edition – easing security testing by non-security professionals (download now)

 

 


Latest postings for ASP/ VbScript.
Click here to see a screenshot of this code!Mess Officer Management System (Sistem Pengurusan Mess Pegawai)
By Mohd Fauzi on 11/23

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

Input Date

Print
Email
 
VB icon
Submitted on: 7/18/2000 10:42:49 AM
By: Lewis E. Moten III  
Level: Intermediate
User Rating: Unrated
Compatibility:ASP (Active Server Pages), VbScript (browser/client side)

Users have accessed this code 16216 times.
 
author picture
(About the author)
 
     This small snippet will generate 3 drop down boxes that will allow your users to choose a date.

 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    '**************************************
    ' for :Input Date
    '**************************************
    Copyright (C) 1999 by Lewis Moten. All rights reserved.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: Input Date
    ' Description:This small snippet will ge
    '     nerate 3 drop down boxes that will allow
    '     your users to choose a date.
    ' By: Lewis E. Moten III
    '
    ' Inputs:asName - String representing th
    '     e name that you want the field to be pas
    '     sed as. The three fields will be passed 
    '     as [anName].Month, [anName].Day, [anName
    '     ].Year.
    adDate - The current date that will be selected. This is parsed into the Month, Day, and Year if it is a valid date.
    '
    ' Returns:This function returns HTML cod
    '     e for three "SELECT" boxes next to each 
    '     other.
    '
    ' Assumes:It is expected that you have o
    '     pened a FORM element before writing out 
    '     the results from this function. Also, yo
    '     u should know how to grab form data. An 
    '     additional function has been provided to
    '     parse posted data from this function.
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=6263&lngWId=4    'for details.    '**************************************
    
    <%
    ' --------------------------------------
    '     ---------------------------------------
    ' Name:		Input Date Select Boxes
    ' Description:
    '		Allows users to choose a date from 3 
    '     <SELECT> fields
    '		(Month, Day, and Year)
    '
    ' Author:	Lewis Moten
    ' Email:	lewis@moten.com
    ' URL:		http://www.lewismoten.com
    ' --------------------------------------
    '     ---------------------------------------
    ' Returns 3 HTML Selection boxes to pick
    '     a date
    function InputDate(ByRef asName, ByRef adDate)
    	Dim lnDay			' Day
    	Dim lnMonth			' Month
    	Dim lnYear			' Year
    	
    	Dim lnIndex			' Counter
    	
    	Dim lsHTML			' HTML To be returned
    	' if a valid Date was received	
    	if IsDate(adDate) Then
    		' Parse the Month, Day, and Year from the Date
    		lnMonth = Month(adDate)
    		lnDay = Day(adDate)
    		lnYear = Year(adDate)
    	Else
    		' Initialize Month, Day, and Year as Not being chosen
    		lnMonth = -1
    		lnDay = -1
    		lnYear = -1
    	End if
    	' ----- MONTH
    	
    	' Create the month selection field
    	lsHTML = "<Select name=""" & asName & ".Month"">" & vbCrLf
    	
    	' Add empty option - say field is month
    	lsHTML = lsHTML & "<OPTION value="""">Month</OPTION>" & vbCrLf
    	
    	' Loop through Each month
    	For lnIndex = 1 To 12
    		
    		' Create an option With the numeric value of the month
    		lsHTML = lsHTML & "<OPTION value=""" & lnIndex & """"
    		
    		' Select the option if it matches the parsed month
    		if lnIndex = lnMonth Then lsHTML = lsHTML & " selected"
    		
    		' Add the name of the month as the text of the option
    		lsHTML = lsHTML & ">" & MonthName(lnIndex, False) & "</OPTION>" & vbCrLf
    	
    	Next
    	
    	' Close the Month selection field
    	lsHTML = lsHTML & "</Select>" & vbCrLf
    	
    	' ----- DAY
    	
    	' Create the day selection field
    	lsHTML = lsHTML & "<Select name=""" & asName & ".Day"">" & vbCrLf
    	
    	' Add empty option - say field is day
    	lsHTML = lsHTML & "<OPTION value="""">Day</OPTION>" & vbCrLf
    	
    	' Loop through 1 To max days In a month
    	For lnIndex = 1 To 31
    		
    		' create option With numeric value of day
    		lsHTML = lsHTML & "<OPTION value=""" & lnIndex & """"
    		
    		' Select option if it matches parsed day
    		if lnIndex = lnDay Then lsHTML = lsHTML & " selected"
    		
    		' add the value of the day as the text To the option
    		lsHTML = lsHTML & ">" & lnIndex & "</OPTION>" & vbCrLf
    		
    	Next
    	
    	' close the day selection field
    	lsHTML = lsHTML & "</Select>" & vbCrLf
    	' ----- YEAR
    	
    	' Create the year selection field
    	lsHTML = lsHTML & "<Select name=""" & asName & ".Year"">" & vbCrLf
    	
    	' Add empty option - say field is year
    	lsHTML = lsHTML & "<OPTION value="""">Year</OPTION>" & vbCrLf
    	
    	' Loop from highest 4 digit year To lowest.
    	' range is 5 years from now To 100 years ago
    	For lnIndex = (Year(Date()) + 5) To (Year(Date()) - 100) Step -1
    	
    		' create option With year
    		lsHTML = lsHTML & "<OPTION value=""" & lnIndex & """"
    		
    		' Select option if year matches parsed year
    		if lnIndex = lnYear Then lsHTML = lsHTML & " selected"
    		
    		' write the year as the text of the option
    		lsHTML = lsHTML & ">" & lnIndex & "</OPTION>" & vbCrLf
    	Next
    	
    	' close the year selection field
    	lsHTML = lsHTML & "</Select>" & vbCrLf
    	
    	' -----
    	
    	' Return the HTML that creates the Date Picker
    	InputDate = lsHTML
    	
    End function
    ' --------------------------------------
    '     ---------------------------------------
    ' Parse a date comming from InputDate co
    '     mbination fields
    function GetInputDate(ByRef asName)
    	
    	Dim ldDate
    	Dim lnDay
    	Dim lnMonth
    	Dim lnYear
    	
    	lnDay = Request.Form(asName & ".Day")
    	lnMonth = Request.Form(asName & ".Month")
    	lnYear = Request.Form(asName & ".Year")
    	
    	ldDate = lnMonth & "/" & lnDay & "/" & lnYear
    	
    	if IsDate(ldDate) Then
    		GetInputDate = CDate(ldDate)
    	End if
    	
    End function
    ' --------------------------------------
    '     ---------------------------------------
    %>


Other 102 submission(s) by this author

 

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
7/6/2001 6:36:04 PMBig Daddy

i copied and pasted as intructed... still cant get it to work. it displays nothing...
(If this comment was disrespectful, please report it.)

 
3/3/2003 7:56:35 AM

I got the same....displays nowt!
(If this comment was disrespectful, please report it.)

 
3/30/2003 10:42:04 AM

can you help me ?
I got nothingto see
pls help me , i'm need your code for my school project thx!!!

(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2008 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.