Adding multiple actions to a form
Posted on 2005-03-07
I have a Coldfusion form, commentform.cfm, which is used to collect information from a user and input that data into a database then subsequently open a thankyou.cfm page which thanks the user and redirects them to another page. The data is input to the database using the Insert Record Server Behavior. Everything works fine.
Now I would like to add two features:
1. When the user inputs their information to specific fields that appear on commentform.cfm, for example, their first name which they input to the fname field, I would like to create a cookie so that when the user returns to commentform.cfm, the fname field is already completed for them.
2. When the user presses the submit form, which inputs a new record to the database, I would like to have an email sent to myself so that I know a record has been added to the database.
From what I've read on the subject, I think that I can set the cookie by placing the code
<cfcookie name="fname" value="#FORM.fname#">
in the thankyou.cfm page and have the commentform.cfm form action set to post to thankyou.cfm. But when I look at the existing form tag code as it is in commentform.cfm, it reads:
<form action="<cfoutput>#CurrentPage#?#CGI.QUERY_STRING#</cfoutput>" method="POST" name="frm_comment" id="frm_comment" onsubmit="MM_validateForm('email','','NisEmail');return document.MM_returnValue">
Being a novice in Coldfusion, I don't want to destroy the successful functionality of my form as it is now since it does what I need it to do but I am afraid to try to add another action attribute to my form because I cannot find any documentation that says I can do that and I don't know any other way to create that functionality.
In addition, I don't know how to code the email that I would like sent to myself or how I would also add that function to the submit button.
Might anyone help?