?
Solved

CF how to pass date values

Posted on 2011-04-26
1
Medium Priority
?
270 Views
Last Modified: 2012-05-11
<cflocation url="http://localhost/inquiry.aspx?date=#form.txtDate#&nights=#form.txtNights#&rooms=#form.txtRooms#&adults=#form.txtAdults#&child=#form.txtChild#&rateCode=#form.txtCode#" addtoken="no">

In Cold Fusion, I need to quickly change a form such that I don't use a calendar picker but rather a dropdown list for day-month-year, such that only several months of the year are offered in the dropdown. It will be a form with the days of the month and months of the year 2011, instead of a calendar. I want to cover, for example May to Nov 2011.

Because the date values of the form will need to be passed to the above cflocation url, can you help me how to do this ?

hope you understand what I want to do, (I'm not an IT guy), let me know if you need furhter clarification.

thanks, Clifford
0
Comment
Question by:CliffordNg
1 Comment
 
LVL 6

Accepted Solution

by:
cfEngineers earned 2000 total points
ID: 35469709

<!--- place this in the top of your page, or use it in a cfc --->
<cffunction name="showCalendar" output="true">
	<cfargument name="selectedDate" required="no" default="">
	<cfargument name="daySelectName" type="string" required="yes">
	<cfargument name="monthSelectName" type="string" required="yes">
	<cfargument name="yearSelectName" type="string" required="yes">
	<cfargument name="showTable" type="string" required="no" default="true">
		
		<cfif selectedDate EQ "" OR NOT isDate(selectedDate)>
			<cfset sSelectedDay = "">
			<cfset sSelectedMonth = "">
			<cfset sSelectedYear = "">
			<cfif FindNoCase("birth", daySelectName)>
				<cfset sDefaultYear = "1965">
			<cfelse>
				<cfset sDefaultYear = "2000">
			</cfif>
		<cfelse>
			<cfset sSelectedDay = Day(selectedDate)>
			<cfset sSelectedMonth = Month(selectedDate)>
			<cfset sSelectedYear = Year(selectedDate)>
			<cfset sDefaultYear = sSelectedYear>
		</cfif>
			
		<cfset iYearNow = Year(Now())>
		
		<cfif showTable>
			<table><tr><td>
		</cfif>
		
		<select class="slctMonth" id="#monthSelectName#" name="#monthSelectName#">
			<option value="">Month</option>
			<cfloop from="1" to="12" index="iMonth">
				<cfif iMonth EQ sSelectedMonth>
					<option value="#iMonth#" selected>#iMonth# (#left(MonthAsString(iMonth),3)#)</option>
				<cfelse>
					<option value="#iMonth#"><cfif iMonth LT 10>0</cfif>#iMonth# (#left(MonthAsString(iMonth),3)#)</option>
				</cfif>
			</cfloop>
		</select>
		
		<select class="slctDay" id="#daySelectName#" name="#daySelectName#">
			<option value="">Day</option>
			<cfloop from="1" to="31" index="iDay">
				<cfif iDay EQ sSelectedDay>
					<option value="#iDay#" selected>#iDay#</option>
				<cfelse>
					<option value="#iDay#">#iDay#</option>
				</cfif>
			</cfloop>
		</select>
		
		<select class="slctYear" id="#yearSelectName#" name="#yearSelectName#">
			<option value="">Year</option>
			<cfloop from="#iYearStart#" to="#iYearNow#" index="iYear">
				<cfif iYear EQ sSelectedYear>
					<option value="#iYear#" selected>#iYear#</option>
				<cfelse>
					<option value="#iYear#">#iYear#</option>
				</cfif>
			</cfloop>
		</select>
		<cfif showTable>
			</td></tr></table>
		</cfif>
</cffunction>
<!---  --->

<!--- usage below --->
<cfoutput>
#showCalendar(selectedDate="#birthDate#",daySelectName="birthDaySelect",monthSelectName="birthMonthSelect",yearSelectName="birthYearSelect")#
</cfoutput>

Open in new window

0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Integration Management Part 2
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question