Hi,

I nicked this self-same code from a free calander from the old macromedia
developer exchange.

I can't claim any credit or this... but I may have changed some variable
names.. stramge how similiar it appears to the previous post!!


<!--- Set the month and year parameters to equal the current values if they do not 
exist. --->
<CFPARAM NAME = "month" DEFAULT = "#DatePart('m', Now())#">
<CFPARAM NAME = "year" DEFAULT = "#DatePart('yyyy', Now())#">

<!--- Set the requested (or current) month/year date and determine the number of days 
in the month. --->
<CFSET ThisMonthYear = CreateDate(year, month, '1')>
<CFSET Days = DaysInMonth(ThisMonthYear)>

<!--- Set the values for the previous and next months for the back/next links. --->
<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)>

<!--- The Table cell width --->
<CFSET CellWidth = "50">

<br>
<TABLE BORDER = "0">
        <TR>
                <TD ALIGN = "center">
                        <CFOUTPUT>
                                <!--- Go Back to Previous Month --->
                                <A 
HREF="calendar.cfm?month=#LastMonth#&year=#LastYear#">&lt;&lt;</A>
                                
&nbsp;&nbsp;#MonthAsString(month)#&nbsp;#year#&nbsp;&nbsp;
                                <!--- Go Foward To Next Month --->
                                <A HREF = 
"calendar.cfm?month=#NextMonth#&year=#NextYear#">&gt;&gt;</A>
                        </CFOUTPUT><P>
                        
                        <TABLE BORDER = "1">
                                <!--- Display Day Heading in First Table row --->
                                <TR>
                                        <CFLOOP FROM = "1" TO = "7" INDEX = "LoopDay">
                                                
                                                        <TD WIDTH = 
"<cfoutput>#CellWidth#</CFOUTPUT>" ALIGN = 
"center"><CFOUTPUT>#Left(DayOfWeekAsString(LoopDay), 1)#</CFOUTPUT></TD>

                                        </CFLOOP>
                                </TR>
                                
                                <!--- Set the ThisDay variable to 0.  This value will 
remain 0 until 
                                      the day of the week on which the 
                                      first day of the month falls on is reached. --->
                                <CFSET ThisDay = 0>
                                
                                <!--- Loop through until the number of days in the 
month is reached.  --->
                                <CFLOOP CONDITION = "ThisDay LTE Days">
                                        <TR>
                                        <!--- Loop through each day of the week. --->
                                        <CFLOOP FROM = "1" TO = "7" INDEX = "LoopDay">
                                                <!--- If ThisDay is still 0, check to 
see if the current day of the week in the loop --->
                                                <!--- matches the day of the week for 
the first day of the month. --->
                                                <!--- If the values match, set ThisDay 
to 1. --->
                                                <!--- Otherwise, the value will remain 
0 until the correct day of the week is found. --->
                                                <CFIF ThisDay IS 0>
                                                        <CFIF DayOfWeek(ThisMonthYear) 
IS LoopDay>
                                                                <CFSET ThisDay = 1>
                                                        </CFIF>
                                                </CFIF>
                                                <!--- If the ThisDay value is still 0, 
or it is greater than the number of days in the month, --->
                                                <!--- display nothing in the column. 
--->
                                                <!--- Otherwise, display the day of 
the month and increment the value. --->
                                                <CFIF (ThisDay IS NOT 0) AND (ThisDay 
LTE Days)>
                                                        <CFOUTPUT>
                                                                <TD 
WIDTH="#CellWidth#">
                                                                        #ThisDay#<br>
                                                                </TD>
                                                        </CFOUTPUT>
                                                        <CFSET ThisDay = ThisDay + 1>
                                                <CFELSE>
                                                        <TD>&nbsp;</TD>
                                                </CFIF>
                                        </CFLOOP>
                                        </TR>
                                </CFLOOP>
                        </TABLE>
                </TD>
        </TR>
</TABLE>

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to