在 ColdFusion cfinput 中动态设置 "Readonly"
Dynamically set "Readonly" in ColdFusion cfinput
是否可以使用 cfif
语句将 "Readonly" 添加到我的
?
我的URL(示例):
http://www.mywebsite.com/folder/page_review.cfm?action=view&rfqID=2
例如:
<cfset pageAction="URL.action">
<cfset rfqID="URL.rfqID">
<label>*Sales Engineer:</label>
<cfinput type="text" name="sales_engineer"
value="" class="rfq_text_input"
<cfif pageAction eq "view"> readonly</cfif>/>
我的理论为什么它不起作用是因为我是 运行 输入中的 if 语句。但我不确定如何对此进行测试。
您不能像这样嵌套标签:
<cfinput etc <cfif>whatever</cfif> >
您可以使用简单的输入标签来做到这一点。否则,你必须做这种事情。
<cfif whatever>
<cfinput something>
<cfelse>
<cfinput something else>
</cfif>
如果你坚持使用cfinput
,标签有只读属性。当您想要阻止用户在字段中输入表单时,有条件地将属性文本设置为空字符串以外的值。
<cfform>
<cfoutput>
<!--- Readonly attribute of cfinput (Read only) --->
<cfinput type="text" name="text" readOnly="#(true)?"ReadOnly":""#" value="read only">
<!--- Readonly attribute of cfinput (editable) --->
<cfinput type="text" name="text2" readOnly="#(false)?"ReadOnly":""#" value="editable">
<!--- HTML input --->
<input type="text" name="text3" #(true)?"ReadOnly":""# value="read only" />
</cfoutput>
</cfform>
是否可以使用 cfif
语句将 "Readonly" 添加到我的 ?
我的URL(示例):
http://www.mywebsite.com/folder/page_review.cfm?action=view&rfqID=2
例如:
<cfset pageAction="URL.action">
<cfset rfqID="URL.rfqID">
<label>*Sales Engineer:</label>
<cfinput type="text" name="sales_engineer"
value="" class="rfq_text_input"
<cfif pageAction eq "view"> readonly</cfif>/>
我的理论为什么它不起作用是因为我是 运行 输入中的 if 语句。但我不确定如何对此进行测试。
您不能像这样嵌套标签:
<cfinput etc <cfif>whatever</cfif> >
您可以使用简单的输入标签来做到这一点。否则,你必须做这种事情。
<cfif whatever>
<cfinput something>
<cfelse>
<cfinput something else>
</cfif>
如果你坚持使用cfinput
,标签有只读属性。当您想要阻止用户在字段中输入表单时,有条件地将属性文本设置为空字符串以外的值。
<cfform>
<cfoutput>
<!--- Readonly attribute of cfinput (Read only) --->
<cfinput type="text" name="text" readOnly="#(true)?"ReadOnly":""#" value="read only">
<!--- Readonly attribute of cfinput (editable) --->
<cfinput type="text" name="text2" readOnly="#(false)?"ReadOnly":""#" value="editable">
<!--- HTML input --->
<input type="text" name="text3" #(true)?"ReadOnly":""# value="read only" />
</cfoutput>
</cfform>