Skip to main content
Participant
May 2, 2006
Answered

CFFORM Conditional Action

  • May 2, 2006
  • 1 reply
  • 373 views
I am wondering if you can nest a cfif inside the action attribute of the cfform tag. I would like to specify two different form actions depending on the existance of a record in a record set. Something like this:

<cfform id="form1" name="form1" method="post" action=
<cfif #Form.subid# = #ExistsSubid.subid#>
"Action1.cfm"
<cfelse>
"Action2.cfm"
</cfif>
>
ExistsSubid is the name of the record set, and the form.subid contains the value I would like to compare with the record set.
This topic has been closed for replies.
Correct answer BKBK
Causes much fewer headaches:

<cfif Form.subid EQ ExistsSubid.subid>
<cfset actionPage = "Action1.cfm">
<cfelse>
<cfset actionPage = "Action2.cfm">
</cfif>

<cfform id="form1" name="form1" method="post" action="#actionPage#">


1 reply

BKBK
Community Expert
BKBKCommunity ExpertCorrect answer
Community Expert
May 2, 2006
Causes much fewer headaches:

<cfif Form.subid EQ ExistsSubid.subid>
<cfset actionPage = "Action1.cfm">
<cfelse>
<cfset actionPage = "Action2.cfm">
</cfif>

<cfform id="form1" name="form1" method="post" action="#actionPage#">