Important alert: (current site time 7/15/2013 11:09:35 PM EDT)
 

VB icon

A Date Picker using HTML Combos

Email
Submitted on: 12/19/2001 12:32:53 AM
By: Adam Taylor 
Level: Beginner
User Rating: By 4 Users
Compatibility: ASP (Active Server Pages)
Views: 23284
(About the author)
 
     i didn't like any of the active x date pickers i found and couldn't find any other decent ones to work with the way i was programming a page, so i just made this. it combines 3 HTML combos each with the 3 parts of a date in them, gets the values when a button is pressed and combines them into one string to create a valid date in australian format and american format (ie 18/12/2001 and 12/18/2001)
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
' for :A Date Picker using HTML Combos
'**************************************
you can use it if you want, i don't mind, really
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: A Date Picker using HTML Combos
' Description:i didn't like any of the active x date pickers i found and couldn't find any other decent ones to work with the way i was programming a page, so i just made this. it combines 3 HTML combos each with the 3 parts of a date in them, gets the values when a button is pressed and combines them into one string to create a valid date in australian format and american format (ie 18/12/2001 and 12/18/2001)
' By: Adam Taylor
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=7069&lngWId=4'for details.'**************************************

'creates first combo box for day
 Response.Write "<select name = cboDayFrom>"
 Response.Write "<option></option>"
 'loops through and puts numbers 1 - 31 in the combo box
 For i = 1 to 31
Response.Write "<option>"&i&"</option>"
 next 
 Response.Write "</select>"
 i = 0
 'creates the 2nd combo box for months and puts each month in the combo
 Response.Write "<select name=cboMonthFrom>"
 Response.Write "<option></option>"
 Response.Write "<option value=1>January</option>"
 Response.Write "<option value=2>February</option>"
 Response.Write "<option value=3>March</option>"
 Response.Write "<option value=4>April</option>"
 Response.Write "<option value=5>May</option>"
 Response.Write "<option value=6>June</option>"
 Response.Write "<option value=7>July</option>"
 Response.Write "<option value=8>August</option>"
 Response.Write "<option value=9>September</option>"
 Response.Write "<option value=10>October</option>"
 Response.Write "<option value=11>November</option>"
 Response.Write "<option value=12>December</option>"
 Response.Write "</select>"
 
 'creates the 3rd combo for years and puts years up to 2010 in
 Response.Write "<select name=cboYearFrom>"
 Response.Write "<option></option>"
 Response.Write "<option>2001</option>"
 Response.Write "<option>2002</option>"
 Response.Write "<option>2003</option>"
 Response.Write "<option>2004</option>"
 Response.Write "<option>2005</option>"
 Response.Write "<option>2006</option>"
 Response.Write "<option>2007</option>"
 Response.Write "<option>2008</option>"
 Response.Write "<option>2009</option>"
 Response.Write "<option>2010</option>"
 Response.Write "</select>"
' draw the button 
 Response.Write("<Input name=btnFiltertype=submit value=""Filter"">")
'assigns the values of each combo to the variables
 FilterDayFrom = Request.Form("cboDayFrom")
 FilterMonthFrom = Request.Form("cboMonthFrom")
 FilterYearFrom = Request.Form("cboYearFrom")
'checks to make sure each combo box has a value in it
 'if it doesn't, then it displays a message
 if FilterDayFrom <> "" and FilterMonthFrom <> "" and FilterYearFrom = "" then
Response.Write "Please enter a year from."
 elseif FilterDayFrom <> "" and FilterMonthFrom = "" and FilterYearFrom <> "" then
Response.Write "Please enter a month from."
 elseif FilterDayFrom = "" and FilterMonthFrom <> "" and FIlterYearFrom <> "" then
Response.Write "Please enter a day From."
 elseif FilterDayFrom <> "" and FilterMonthFrom = "" and FilterYearFrom = "" then
Response.Write "Please enter a month from and a year from."
 elseif FilterDayFrom = "" and FilterMonthFrom = "" and FilterYearFrom <> "" then
Response.Write "Please Enter a day From and a Month From."
 elseif FilterDayFrom = "" and FilterMonthFrom <> "" and FilterYearFrom <> "" then
Response.Write "Please enter a day From."
 elseif FilterDayFrom = "" and FilterMonthFrom <> "" and FIlteryearFrom = "" then
Response.Write "Please enter a day from and a year from."
 elseif FilterDayTo <> "" and FilterMonthTo <> "" and FilterYearTo <> "" and FilterDayFrom = "" and FilterMonthFrom = "" and FilterYearFrom = "" then
Response.Write "Please enter a day from, a month from and a year from"
 'if all the combo boxes have a value in them, then it joins
 'each of the values into one string for american date
 ' and one string for australian date
 elseif FilterDayFrom <> "" and FilterMonthFrom <> "" and FilterYearFrom <> "" then
FilterDateFrom = FilterMonthFrom &"/"&FilterDayFrom&"/"&FilterYearFrom
ViewDateFrom = FilterDayFrom &"/"&FilterMonthFrom&"/"&FilterYearFrom
 end if


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell 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 Beginner 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

4/17/2002 12:41:06 AMAnand

This code does not perform the basic validation ...i,e.it is not checking for a date more than 28 in the month of febrauary.where max days is 28 or leap year...Pls Revert ,
Regards Anand.
(If this comment was disrespectful, please report it.)

 
12/30/2002 7:03:29 AM

How do you transfer the values in the combo to an excel database, send reply to rkayasth@yahoo.com

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

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.