two submit buttons..

Try setting the tab order using tabindex:

<%= image_submit_tag( "buttons/ok.gif",
                                        :border => "0",
                                        :title => 'Submit page',
                                        :id => 'ok_button',
                                        :tabindex => 13) %>

Just make sure that your OK button is earlier in the tabindex order than the Cancel button.

Here are some references:


Kad Kerforn wrote:

On this two submit button subject, have anyone successfully tried the
":name" technique in a form_remote_tag case? In the following example,
params[:preview] and params[:ok] are both present, so can't tell which
button is clicked, any idea how to get around this?

<%= form_remote_tag ..>
  <image_submit_tag("ok.gif", :name=>"ok")%>
  <image_submit_tag("preview.gif", :name=>"preview")%>
<%= end_form_tag %>



if i remember correctly, the way around this is to have a hidden field
in the form and when you click the submit button, you set the value on
the hidden field to indicate what button was clicked. you can then
check this hidden field value on the server.

hmm ... not sure why this can work. If I understand it correctly, A
hidden field is part of the submitted form, not associated with the
submit button. <%= hidden_field_tag ... %> will be submitted along
with the rest of the form, but still not sufficient to make a
distinction. Maybe I get you wrong, an example will be good.

thanks for the reply.


off the top of my head...not tested. not even sure if you need the
submit() call in the onclicks as it may still get submitted because of
the submit buttons. give it a shot.

<%= form_remote_tag ..., :html => { :id => 'my_form' } %>
  <%= submit_tag "Delete", :onclick => "$('form_action').value =
'delete';$('my_form').submit()" %>
  <%= submit_tag "Update", :onclick => "$('form_action').value =
'update';$('my_form.submit();" %>
  <%= hidden_field_tag "form_action", "", :id => "form_action" %>
<%= end_form_tag %<