# HTML Forms

**URL:** <https://www.ruby-forum.com/t/html-forms/151732>\
**Category:** Rails\
**Created:** [October 24, 2008, 10:06pm UTC](https://www.ruby-forum.com/t/html-forms/151732 "2008-10-24T22:06:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaikishan\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ad7895/32.png) [@Jaikishan\_J](https://www.ruby-forum.com/u/Jaikishan_J)\
**Post date:** [October 24, 2008, 10:06pm UTC](https://www.ruby-forum.com/t/html-forms/151732/1 "2008-10-24T22:06:21Z")

</div>

Hello,  
I have a form with two buttons - [1] Create [2] Cancel. By default if a  
user  
clicks on any of them, the form gets submitted. However, I dont want to  
do  
that. I want to call a javascript function on cancel and form submit (as  
usual) on create. How can this be achieved?

–  
Thanks,  
Jaikishan

---

<div class="post-metadata">

**Author:** ![Jaikishan\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ad7895/32.png) [@Jaikishan\_J](https://www.ruby-forum.com/u/Jaikishan_J)\
**Post date:** [October 24, 2008, 10:53pm UTC](https://www.ruby-forum.com/t/html-forms/151732/2 "2008-10-24T22:53:14Z")

</div>

Well where do you want the cancel button to go ? reset the form and  
back to the new task? or some other page?

Just use a link\_to or button\_to for the cancel button… Don’t make it  
part of the form…

---

<div class="post-metadata">

**Author:** ![Jaikishan\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ad7895/32.png) [@Jaikishan\_J](https://www.ruby-forum.com/u/Jaikishan_J)\
**Post date:** [October 24, 2008, 11:19pm UTC](https://www.ruby-forum.com/t/html-forms/151732/3 "2008-10-24T23:19:37Z")

</div>

On Fri, Oct 24, 2008 at 1:05 PM, Jaikishan J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I have a form with two buttons - [1] Create [2] Cancel. By default if a user  
> clicks on any of them, the form gets submitted.

So why is ‘Cancel’ a submit button? Make it a reset button and attach  
your handler to it.

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid
