# Submit\_to\_remote button names and method calls

**URL:** <https://www.ruby-forum.com/t/submit-to-remote-button-names-and-method-calls/189714>\
**Category:** Rails\
**Created:** [June 6, 2010, 12:14am UTC](https://www.ruby-forum.com/t/submit-to-remote-button-names-and-method-calls/189714 "2010-06-06T00:14:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nhaberly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9e8a1a/32.png) [@nhaberly](https://www.ruby-forum.com/u/nhaberly)\
**Post date:** [June 6, 2010, 12:14am UTC](https://www.ruby-forum.com/t/submit-to-remote-button-names-and-method-calls/189714/1 "2010-06-06T00:14:48Z")

</div>

I have an HTML.erb file that defines 2 text\_area\_tags (input, output)  
and 3 submit\_to\_remote buttons (rewrite, demo, clear). Depending on  
which button is clicked, I’d like to call the corresponding Ruby method  
on the server and then update the web page. My problem is that, no  
matter which button is clicked, the same method (input\_output) is always  
called. I thought I could set the :action within the button definition  
to specify the method to call, but it looks like the :action specified  
in the form will always be called. How can I make each button call a  
different method? Alternatively, how can I display the name of the  
button that was clicked within the method that is being called? The  
html.erb file is below. Thank you in advance for your help.

 \<%= javascript\_include\_tag :defaults %\> \<%= stylesheet\_link\_tag 'input\_output' %\>

```
<div id="input_output_form">
<% form_tag(:action=>:input_output) do %>

    <%= text_area_tag(:input, params[:input], :size=>"80x11") %>
    <p></p>

  <%= submit_to_remote 'Rewrite','Rewrite',
                :action=>'rewrite',
                :update=>'input_output_form',
                :html=>{:class=>"btn",
                        :onmouseover=>"this.className='btn btnhov'",
                        :onmouseout=>"this.className='btn'"} %>
  <%= submit_to_remote 'Demo','Demo',
                :action=>:demo,
                :update=>'input_output_form',
                :html=>{:class=>"btn",
                        :onmouseover=>"this.className='btn btnhov'",
                        :onmouseout=>"this.className='btn'"} %>
  <%= submit_to_remote 'Clear','Clear',
                :action=>':clear',
                :update=>'input_output_form',
                :html=>{:class=>"btn",
                        :onmouseover=>"this.className='btn btnhov'",
                        :onmouseout=>"this.className='btn'"} %>

  <p></p>

```

\<%= text\_area\_tag(:output, params[:output], :size=\>“80x11”) %\>

\<%= text\_area\_tag(:scratchpad, params[:scratchpad], :size=\>“80x11”) %\>

```
<% end %>
</div>

```
