We have a schedule that is dynamically generated using, in part, this code:
<cfloop from="0" to="6" index="x">
<cfset thisDate = dateFormat(dateAdd("d",x,theDate),"yyyy-mm-dd")>
<cfoutput><tr><td colspan="4" class="date"><strong>#dateFormat(thisDate,"DDDD, M/D")#</strong></td></tr></cfoutput>
<cfif structKeyExists(dayData,thisDate)>
<cfif arrayLen(dayData[thisDate]) gt 0>
<cfloop from="1" to="#arrayLen(dayData[thisDate])#" index="y">
<cfoutput><tr>#dayData[thisDate][y]#</tr></cfoutput>
</cfloop>
<cfelse>
<cfoutput><tr><td colspan="4">There are no classes scheduled for this day</td></tr></cfoutput>
</cfif>
<cfelse>
<cfoutput><tr><td colspan="4">Schedule not available</td></tr></cfoutput>
</cfif>
</cfloop>
What I’m trying to do is dynamically insert an anchor (e.g., < a name=”anchor”>) depending on whether the date in the displayed row is the current date. So I want a cfif that will display the anchor on the row of the current day in the schedule. The goal is to link to this using the anchor.
Any suggestions are much appreciated.
So something like this?
BTW, did you know you can loop over dates in ColdFusion.
This assumes that the dates are in a format that CF sees as dates, like what now() returns.