ColdFusion Calendar - How can I find day from days in month?
Here's my code. I got it from a tutorial online.
<CFPARAM NAME = "month" DEFAULT = "#DatePart('m', Now())#" />
<CFPARAM NAME = "year" DEFAULT = "#DatePart('yyyy', Now())#" />
<CFPARAM NAME = "currentday" DEFAULT = "#DatePart('d', Now())#" />
<CFPARAM NAME = "startmonth" DEFAULT = "#DatePart('m', Now())#" />
<CFPARAM NAME = "startyear" DEFAULT = "#DatePart('yyyy', Now())#" />
<cfset ThisMonthYear = CreateDate(year, month, '1') />
<cfset Days = DaysInMonth(ThisMonthYear) />
<cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear) />
<cfset LastMonth = DatePart('m', LastMonthYear) />
<cfset LastYear = DatePart('yyyy', LastMonthYear) />
<cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear) />
<cfset NextMonth = DatePart('m', NextMonthYear) />
<cfset NextYear = DatePart('yyyy开发者_如何转开发', NextMonthYear) />
and here is my output code.
<a href="calendar_day.cfm?month=#month#&day=#THE_DAY#&year=#year#">
I'm using this for a visible calendar, and want to be able to select the day from all days in the month. Is there any way to determine the day of the month when clicking on the day in the monthly calendar view?
I believe what you want to use is #URL.day#
, to get the day variable passed in the URL, but as everyone is saying your question is really confusing.
As pointed out, the question is pretty confusing.
Is there any way to determine the day of the month when clicking on the day in the monthly calendar view?
You have total number of days in the month in Days var. On the calendar render, you are likely looping through and displaying each day of the month using that var. You can easily embed that loop index into your resulting HTML to know what day any given link would refer to.
<!--- loop thru all days in current month --->
<cfloop from=1 to=Days index="this_day">
<!--- display day in the calendar --->
<a href="calendar_day.cfm?month=#month#&day=#this_day#&year=#year#">Day #this_day#</a>
<cfif this_day eq CurrentDay>
<!--- day being displayed is the current day, highlight it or whatever --->
</cfif>
</cfloop>
精彩评论