我们有一个部分使用以下代码动态生成的时间表:
<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>
我想做的是根据显示行中的日期是否是当前日期动态插入 anchor (例如,)。所以我想要一个 cfif 来显示时间表中当天的行上的 anchor 。目标是使用 anchor 链接到此。
非常感谢任何建议。
最佳答案
所以是这样的吗?
<cfif dateFormat(now()),"yyyy-mm-dd") eq thisDate>
<a name="anchor" />
</cfif>
顺便说一句,您知道可以在 ColdFusion 中循环日期吗?
<cfloop from="#theDate#" to="#dateAdd("d", 6, theDate)#" index="thisDate" step="#CreateTimeSpan( 1, 0, 0, 0 )#">
</cfloop>
这假设日期采用 CF 视为日期的格式,就像 now() 返回的那样。
关于coldfusion - 如果行是当前日期,则插入 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7369259/