Forum: Ruby on Rails submit_tag

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.
A6be7720d668f4f02160b600e67337e2?d=identicon&s=25 Ivan Medda (Guest)
on 2006-02-27 11:42
How can i use the submit_tag method (from: actionView::FormTagHelper)
to create various submit buttons and chose the right action in accord to
the button that i pushed?
B0d6fda6fabb8cda27b5e6dde2dc2ac3?d=identicon&s=25 Simo Addsw (gal)
on 2006-02-27 13:51
Ivan Medda wrote:
> How can i use the submit_tag method (from: actionView::FormTagHelper)
> to create various submit buttons and chose the right action in accord to
> the button that i pushed?

I use javascript and button html tags to do this.


<script type="text/javascript">
  function postAction(form,action){
    form.action="/your_controller/"+action
    form.submit()
  }
</script>

  ...

 <input type="button" value="Action1"
onClick="postAction(this.form,'action1')"/>
 <input type="button" value="Action2"
onClick="postAction(this.form,'action2')"/>

Simo
 addsw.it
A6be7720d668f4f02160b600e67337e2?d=identicon&s=25 Ivan Medda (Guest)
on 2006-02-27 16:09
OK!
Thanks. I found also another method,if it could interest you:

<%= form_tag (:action => :interfaccia) %>
<%= select_tag (:operator, options_for_select(%w{ ivan bambo ask},
@params[:operator])) %>
<%= submit_tag ("premi") %>
<%= submit_tag ("calca") %>
<%= end_form_tag %>


Ivan.


Simo AD.D.SW wrote:
>
> I use javascript and button html tags to do this.
>
>
> <script type="text/javascript">
>   function postAction(form,action){
>     form.action="/your_controller/"+action
>     form.submit()
>   }
> </script>
>
>   ...
>
>  <input type="button" value="Action1"
> onClick="postAction(this.form,'action1')"/>
>  <input type="button" value="Action2"
> onClick="postAction(this.form,'action2')"/>
>
> Simo
>  addsw.it
This topic is locked and can not be replied to.