coldfusion - 如果行是当前日期,则插入 anchor

标签 coldfusion coldfusion-9

我们有一个部分使用以下代码动态生成的时间表:

    <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/

相关文章:

oop - Coldfusion组件可以共享方法而不是同一个父类(super class)的后代吗

windows - ColdFusion 服务器监控 - 不工作

jquery - 错误: "argument passed ... is not of type string."

oracle - 调用 Oracle PL/SQL 过程时使用什么编码

coldfusion - 使用 CFScript 编写时,提示技术之间是否存在非美学差异需要考虑?

coldfusion - 在 CFBuilder 中创建服务器后 RDS 发生故障

redirect - 使用 ColdFusion Model-Glue,如何在登录后将用户重定向回他们请求的页面?

coldfusion - 我们可以在 Coldfusion 中更新 session 吗?

coldfusion - 当名称包含连字符/破折号时从 Form 范围加载 ColdFusion 值

ColdFusion 在 robots.txt 中搜索特定页面异常