|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
||||
|
||||
|
ok im trieing to make a scheduel script like what this page has http://leagues.theigs.com/gr/ViewTe...action=schedule
now i got everything down except for the part where they match up the correct day numbers with the day names based on what month you are viewing. if anyone has a solution please help because i am truly stumped. now this is my code below: Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Scheduel</title>
</head>
<body>
<cfset loopnumber = 1>
<cfset cellcount = 1>
<cfset numberofdays = #DaysInMonth(dateformat(now()))#>
<cfset totalrows = 7>
<cfset totalrowscountdown = totalrows - 0>
<table width="536" cellspacing="10" cellpadding="0" border="0" class="style">
<tr>
<td align="center"><strong>Sun</strong></td>
<td align="center"><strong>Mon</strong></td>
<td align="center"><strong>Tue</strong></td>
<td align="center"><strong>Wed</strong></td>
<td align="center"><strong>Thu</strong></td>
<td align="center"><strong>Fri</strong></td>
<td align="center"><strong>Sat</strong></td>
</tr>
<cfloop index="i" from="1" to="#numberofdays#">
<cfif #cellcount# is 1>
<tr>
</cfif>
<td width="100" align="center" valign="top">
<table width="100" border="0" cellspacing="1" cellpadding="4" bgcolor="666666" class="style">
<tr>
<td height="75" valign="top" bgcolor="<cfif "#day(dateformat(now()))#" is "#loopnumber#">f6f6f6<cfelse>cccccc</cfif>" align="left">
<cfoutput>#loopnumber#</cfoutput>
</td>
</tr>
</table>
</td>
<cfif #cellcount# is 7>
</tr>
</cfif>
<cfset totalrowscountdown = totalrowscountdown - 1>
<cfif #totalrowscountdown# is 0>
<cfset cellsleft = 7 - #cellcount#>
<cfif #cellsleft# is 0>
</tr>
<cfelse>
<cfloop condition="#cellscount# GREATER THAN OR EQUAL TO 1">
<td width="100" align="center"> </td>
<cfset cellscount = cellscount - 1>
<cfif #cellscount# is 0>
</tr>
</cfif>
</cfloop>
</cfif>
</cfif>
<cfif #cellcount# is 7>
<cfset cellcount = 1>
<cfelse>
<cfset cellcount = cellcount + 1>
</cfif>
<cfset loopnumber = #loopnumber# + 1>
</cfloop>
</table>
</body>
</html>
|
|
#2
|
||||
|
||||
|
oooops i posted twice.... eek....
|
|
#3
|
|||
|
|||
|
If you're just trying to output a calendar I think it can be done more simply, something like this:
Code:
<cfoutput> <cfset targetMonth = '12/1/2004' /> <cfset firstDayOfMonthDayOfWeek = dayOfWeek( '#month( targetMonth )#/1/#year( targetMonth )#' ) /> <br /> <cfset dayCounter = 1 /> <cfset monthStarted = false /> <table border="1"> <tr> <td>Sun</td> <td>Mon</td> <td>Tues</td> <td>Wed</td> <td>Thurs</td> <td>Fri</td> <td>Sat</td> </tr> <cfloop condition="#dayCounter# lte #daysInMonth( targetMonth )#"> <tr> <cfloop index="thisDayOfWeek" from="1" to="7"> <td> <cfif firstDayOfMonthDayOfWeek eq thisDayOfWeek and not monthStarted> #dayCounter# <cfset monthStarted = true /> <cfelseif monthStarted and dayCounter lte daysInMonth( targetMonth )> #dayCounter# <cfelse> </cfif> </td> <cfif monthStarted> <cfset dayCounter = dayCounter + 1> </cfif> </cfloop> </tr> </cfloop> </table> </cfoutput>
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#4
|
||||
|
||||
|
ok I got your code to work perfectly but i made some adjustments and now i get an error when i run it on the 11th month of the year. here is my code below.
Code:
<center>
<cfoutput>
<cfset targetMonth = '#monthID#/#day(1)#/#yearID#' />
<cfset firstDayOfMonthDayOfWeek = dayOfWeek( '#month( targetMonth )#/1/#year( targetMonth )#' ) /> <br />
<cfset dayCounter = 1 />
<cfset monthStarted = false />
<cfset nextmonth = #monthID# + 1>
<cfif "#nextmonth#" gt "12">
<cfset nextmonth = 1>
<cfset nextyear = #yearID# + 1>
<cfelse>
<cfset nextyear = #yearID#>
</cfif>
<cfset prevmonth = #monthID# - 1>
<cfif "#prevmonth#" lt "1">
<cfset prevmonth = 12>
<cfset prevyear = #yearID# - 1>
<cfelse>
<cfset prevyear = #yearID#>
</cfif>
<table border="0" class="style" cellpadding="3" cellspacing="2">
<tr>
<td align="center"><strong><a href="index.cfm?pageid=#pageid#&unitpage=#unitpage#&monthID=#prevmonth#&yearID=#prevyear#">Prev Month</a></strong></td>
<td align="center"><strong><a href="index.cfm?pageid=#pageid#&unitpage=#unitpage#&monthID=#monthID#&yearID=#yearID#">Refresh</a></strong></td>
<td align="center"><strong><a href="index.cfm?pageid=#pageid#&unitpage=#unitpage#&monthID=#nextmonth#&yearID=#nextyear#">Next Month</a></strong></td>
<form action="index.cfm" method="post">
<td align="right" colspan="4"></td>
</form>
</tr>
<tr>
<td colspan="7" height="10"></td>
</tr>
<tr>
<td align="center"><strong>Sun</strong></td>
<td align="center"><strong>Mon</strong></td>
<td align="center"><strong>Tues</strong></td>
<td align="center"><strong>Wed</strong></td>
<td align="center"><strong>Thurs</strong></td>
<td align="center"><strong>Fri</strong></td>
<td align="center"><strong>Sat</strong></td>
</tr>
<cfloop condition="#dayCounter# lte #daysInMonth( targetMonth )#">
<tr>
<cfloop index="thisDayOfWeek" from="1" to="7">
<cfif "#len(dayCounter)#" is "1">
<cfset "dayCounter2" = "#right(dayCounter, 1)#">
<cfif "#dayCounter2#" is "1">
<cfset "daytitle" = "st">
<cfelseif "#dayCounter2#" is "2">
<cfset "daytitle" = "nd">
<cfelseif "#dayCounter2#" is "3">
<cfset "daytitle" = "rd">
<cfelse>
<cfset "daytitle" = "th">
</cfif>
<cfelseif "#len(dayCounter)#" is "2">
<cfset "dayCounter2" = "#right(dayCounter, 2)#">
<cfif "#dayCounter2#" is "21" or "#dayCounter2#" is "31">
<cfset "daytitle" = "st">
<cfelseif "#dayCounter2#" is "22" or "#dayCounter2#" is "32">
<cfset "daytitle" = "nd">
<cfelseif "#dayCounter2#" is "23" or "#dayCounter2#" is "33">
<cfset "daytitle" = "rd">
<cfelse>
<cfset "daytitle" = "th">
</cfif>
</cfif>
<td valign="top" width="80" height="80"
<cfif "#dayCounter#" is "#day(dateformat(now()))#" and firstDayOfMonthDayOfWeek eq thisDayOfWeek and not monthStarted>
bgcolor="efefef"
title="Nothing is happening on the #dayCounter##daytitle#"
<cfelseif "#dayCounter#" is "#day(dateformat(now()))#" and monthStarted and dayCounter lte daysInMonth( targetMonth )>
bgcolor="efefef"
title="Nothing is happening on the #dayCounter##daytitle#"
<cfelseif "#dayCounter#" is not "#day(dateformat(now()))#" and firstDayOfMonthDayOfWeek eq thisDayOfWeek and not monthStarted>
bgcolor="cccccc"
title="Nothing is happening on the #dayCounter##daytitle#"
<cfelseif "#dayCounter#" is not "#day(dateformat(now()))#" and monthStarted and dayCounter lte daysInMonth( targetMonth )>
bgcolor="cccccc"
title="Nothing is happening on the #dayCounter##daytitle#"
<cfelse>
</cfif>>
<cfif firstDayOfMonthDayOfWeek eq thisDayOfWeek and not monthStarted>
#dayCounter#
<cfset monthStarted = true />
<cfelseif monthStarted and dayCounter lte daysInMonth( targetMonth )>
#dayCounter#
<cfelse>
</cfif>
</td>
<cfif monthStarted>
<cfset dayCounter = dayCounter + 1>
</cfif>
</cfloop>
</tr>
</cfloop>
<tr>
<td colspan="7" bgcolor="cccccc" align="center">#dateformat(now())#</td>
</tr>
</table>
</cfoutput>
</center>
![]() |
|
#5
|
|||
|
|||
|
What's the error?
![]() |
|
#6
|
||||
|
||||
|
1/31/2004" is an invalid date format. The error occurred on line 4.
|
|
#7
|
|||
|
|||
|
Are you passing in the date with that quote mark at the end? Because 1/31/2004 IS a valid date. But 1/31/2004" is not a valid date due to the quote mark.
|
|
#8
|
||||
|
||||
|
no i just gotgot to copy the starting quote mark along with it. im passing the month and year values in the url.
|
|
#9
|
|||
|
|||
|
Well something must not be passing correctly, because this code returns true:
#isDate( '1/31/2004' )# I'm thinking maybe this part is incorrect: <cfset targetMonth = '#monthID#/#day(1)#/#yearID#' /> Try this instead: <cfset targetMonth = '#monthID#/1/#yearID#' /> |
|
#10
|
||||
|
||||
|
ok yeah that works, any idea why it was doing that?
|
|
#11
|
|||
|
|||
|
The day() function expects a full date, not just a day of the month as a single value.
|
|
#12
|
||||
|
||||
|
cool, i love coming to these forums i learn something new every time
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > a tricky subject |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|