mercredi 14 janvier 2015

ColdFusion multiple submit buttons in form

Question: If I have two buttons in a ColdFusion form one will submit the form to the action.cfm page but the other on submit button I want to load the same page that the form is on again but enter into a statement in the header.


What is happening: Both buttons submit the form to the action.cfm page.


My code example:



//Code in header that should run if the first button is clicked
<cfif StructKeyExists(form,"add_enclosure">
Show the fname variable here.
</cfif>


<cfform action="" method="post" enctype="multipart/form-data">

<cfinput type="text" name="fname">

<cfinput type="submit" value="Add Additional Enclosure" name="add_enclosure"/>

//The button below should not run the logic in the header and only send the user to action.cfm
<cfinput type="submit" value="Submit Current Order" name="submit"/>


</cfform>

Aucun commentaire:

Enregistrer un commentaire