Forum: Ruby on Rails HTML Forms

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jaikishan J. (Guest)
on 2008-10-25 00:06
(Received via mailing list)
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
Freddy A. (Guest)
on 2008-10-25 00:53
(Received via mailing list)
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...
Hassan S. (Guest)
on 2008-10-25 01:19
(Received via mailing list)
On Fri, Oct 24, 2008 at 1:05 PM, Jaikishan J. 
<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
This topic is locked and can not be replied to.