Skip to main content
WolfShade
Legend
April 27, 2011
Question

Conditionals in bind expression

  • April 27, 2011
  • 1 reply
  • 1420 views

Is it possible to put a conditional in a bind expression?

For example:

<cfinput type="text" name="searchParam" id="searchParam">

<cfdiv id="searchResult" bindonload="no" bind="url:sr.cfm?search_param={searchParam@11606534}"></cfdiv>

In this example, sr.cfm will be loaded in the cfdiv EVERY TIME that focus is blurred from the input field.

Is it possible to set it so that the cfdiv will NOT load sr.cfm IF the input field is blank??  Something like:

bind="url:sr.cfm?search_param={searchParam<cfif searchParam neq ''>@11606534</cfif>}"

Is this possible?  Or is there something like it that will work?

Thanks,

^_^

    This topic has been closed for replies.

    1 reply

    Inspiring
    April 28, 2011

    Put your conditional logic into sr.cfm.  If there is no searchparam, return an empty page.

    WolfShade
    WolfShadeAuthor
    Legend
    April 28, 2011

    Dan Bracuk wrote:

    Put your conditional logic into sr.cfm.  If there is no searchparam, return an empty page.

    I'd like to prevent the cfdiv from loading in the first place (if the field is blank), if at all possible.  The field gets focus on initial page load, and I'd like to have it not load anything in the cfdiv if a link is clicked, first.  Currently, the cfdiv loads if a link is clicked, first, due to the @blur.

    ^_^

    WolfShade
    WolfShadeAuthor
    Legend
    April 28, 2011

    WolfShade wrote:

    Dan Bracuk wrote:

    Put your conditional logic into sr.cfm.  If there is no searchparam, return an empty page.

    I'd like to prevent the cfdiv from loading in the first place (if the field is blank), if at all possible.  The field gets focus on initial page load, and I'd like to have it not load anything in the cfdiv if a link is clicked, first.  Currently, the cfdiv loads if a link is clicked, first, due to the @blur.

    ^_^

    Is it possible?  Can conditionals be used between { and } ?

    Thanks,

    ^_^