我想说的是,如果定义了makeCodeNumber
并且不是null,请使用此
<cfpdfformparam name="make" value="#session.checkout.vehicle.makeCodeNumber#">
但如果它为null(或为空)则使用此
<cfpdfformparam name="make" value="#session.checkout.vehicle.vehiclemake#">
所有代码
<cfif isDefined("session.checkout.vehicle.makeCodeNumber")>
<cfif len(trim("session.checkout.vehicle.makeCodeNumber"))>
<cfpdfformparam name="make" value="#session.checkout.vehicle.makeCodeNumber#">
<cfelse>
<cfpdfformparam name="make" value="#session.checkout.vehicle.vehiclemake#">
</cfif>
</cfif>
当我转储变量时,我显示它是null(或空字符串)但由于某种原因我必须忽略某些东西,因为当它为null时它仍然只是<cfpdfformparam name="make" value="#session.checkout.vehicle.makeCodeNumber#">
而不是{{1 }}
非常感谢任何帮助!
答案 0 :(得分:7)
您正在评估字符串“session.checkout.vehicle.makeCodeNumber”的len(trim())
而不是变量session.checkout.vehicle.makeCodeNumber
的值。您需要在第二个if语句中删除"
<cfif isDefined("session.checkout.vehicle.makeCodeNumber")>
<cfif len(trim(session.checkout.vehicle.makeCodeNumber))>
<cfpdfformparam name="make" value="#session.checkout.vehicle.makeCodeNumber#">
<cfelse>
<cfpdfformparam name="make" value="#session.checkout.vehicle.vehiclemake#">
</cfif>
</cfif>