> There Must be something I don't know about CFIF. I want to
> check if a URL variable exists. If it does, I want to add the
> same variable to the URL of the action of a CFForm, basically
> so I can check for it on the action page, and use it to re-route
> a cflocation.
>
> Here's the problem. I have a CFIF that, if it's true, starts
> a CFFORM with the URL variable included in the action, then it
> has a CFELSE that starts the same form, just without the URL
> variable. Problem is, it doesn't work. Tells me that there's an
> extraneous </CFFORM> at the bottom of the template. Basically,
> whether or not the criterion is met, it doesn't start the form.
...
> <cfif IsDefined ('URL.myvariable')>
>    <cfform action=3D"emp_add_action.cfm?myvariable=3Dtrue"
>               method=3D"post" enablecab=3D"Yes">
> <cfelse>
>    <cfform action=3D"emp_add_action.cfm" method=3D"POST"
>               enablecab=3D"Yes">
>
> </cfif>

The problem is that the page is parsed before it's executed, and CF doesn't
know which branch of your CFIF will execute at runtime. Since your closing
CFFORM tag needs an opening CFFORM tag, and CF doesn't know whether there
will actually be an opening CFFORM tag when the parser is doing its thing,
you get a parsing error. You can fix that parsing error by either placing
both your opening and closing CFFORM tags within your conditional logic:

<cfif ...>

        <cfform ...>
        ...
        </cfform>

<cfelse>

        <cfform ...>
        ...
        </cfform>

</cfif>

or you can put both CFFORM tags outside your CFIF:

<cfif ...>
        <cfset MyAction = "emp_add_action.cfm?myvariable=true">
<cfelse>
        <cfset MyAction = "emp_add_action.cfm">
</cfif>

<cfform action="#MyAction#" ...
...
</cfform>

Alternatively, you could just send this as an extra form variable.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to