Coldfusion Query Anchor Element by Id

拈花ヽ惹草 提交于 2019-12-11 12:23:12

问题


I am running a query and am try to output the information using cfoutput like this:

<cfoutput query="the_query">
   <p><a href="#">#QueryResult#</a><p>
</cfoutput>

Coldfusion won't allow me to uses the # in href. It says "Invalid CFML construct", but I need it to be href="#". Is there a way to escape this?


回答1:


Just double up on the # character. ## inside a tag will output a single #.

<cfoutput query="the_query">
   <p><a href="##">#QueryResult#</a><p>
</cfoutput>

No problem putting these up against regular terms, either, say you wanted to name the anchor using a field from the query:

   <p><a href="###QueryResultField#">#QueryResult#</a><p>

This would give you

   <p><a href="#myAnchorName">Result Here</a><p>


来源:https://stackoverflow.com/questions/5809454/coldfusion-query-anchor-element-by-id

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!