Ian:

Pushing enter in a form simply submits the form.  This is different from
pushing a submit button to submit a form.  Submit buttons (can optionally)
have a name and value associated with them.  The name and value of the
button used to submit the form gets sent to the server along with all of the
other form fields.  That is, with the following form:

<FORM ACTION="" METHOD="post">
<INPUT TYPE="input" NAME="foo" VALUE="bar">
<INPUT TYPE="submit" NAME="action" VALUE="insert">
<INPUT TYPE="submit" NAME="action" VALUE="delete">
</FORM>

If you push the "insert" button, action.cfm will see 2 FORM variables, foo
(which equals "bar") and action (which equals "insert").  If the user pushes
the "delete" button, then FORM.action would equal "delete."

Pushing enter will submit the form but action.cfm will only see 1 FORM
variable, foo.  This is because neither of the buttons were activated and,
therefore, neither would be sent to the server.

So, to achieve what you're after, you can setup your form like:

<FORM ACTION="" METHOD="post">
<INPUT TYPE="input" NAME="foo" VALUE="bar">
...
<INPUT TYPE="submit" NAME="action" VALUE="CANCEL">
<INPUT TYPE="submit" NAME="action" VALUE="SUBMIT">
<INPUT TYPE="reset" NAME="action" VALUE="RESET">
</FORM>

And setup your action.cfm like:

<CFIF (NOT isDefined("FORM.Action")) OR (NOT CompareNoCase(FORM.Action,
"CANCEL"))>
<!--- Cancel --->
<CFELSE>
<!--- Submit, because the reset button doesn't submit to the server --->
</CFIF>

--
Mosh Teitelbaum
evoch, LLC
Tel: (301) 942-5378
Fax: (301) 933-3651
Email: [EMAIL PROTECTED]
WWW: http://www.evoch.com/

-----Original Message-----
From: Ian Skinner [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 29, 2003 12:33 PM
To: CF-Talk
Subject: OT multiple submits and the ENTER key

I am planning a form that will have CANCEL, SUBMIT and RESET buttons.  What
I would like to know is there anyway to control which of these is activated
with the enter key?  We would like the CANCEL button to be the default
action if the enter key is pressed, can this be done?

--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA

Confidentiality Notice:  This message including any
attachments is for the sole use of the intended
recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the
intended recipient, please contact the sender and
delete any copies of this message.


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to