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.
20b82a6b37e6570263d17044d7dcb37f?d=identicon&s=25 Jaikishan Jalan (Guest)
on 2008-10-24 22: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
4c438a80fc30661ad619ea177cf9cbd0?d=identicon&s=25 Freddy Andersen (Guest)
on 2008-10-24 22: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...
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2008-10-24 23:19
(Received via mailing list)
On Fri, Oct 24, 2008 at 1:05 PM, Jaikishan Jalan <jai.ism@gmail.com>
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 Schroeder ------------------------ hassan.schroeder@gmail.com
This topic is locked and can not be replied to.