I am using two submit buttons within my form without any problem, as specified (http://www.railsdiary.com/diary/two_submit_buttons) BUT when the user doesn''t hit a button and just hit ENTER, I got the first button submit in my controller which unfortunatly is the Cancel button in my view... Yes, if I change the button position (OK first in html..) I get it.. but I''d like to keep my display as required by the users... Cancel button must come before OK button.... <div class="submit"> <div> <%= submit_tag "Cancel", {:name => "submit", :class => "inputSubmit" }%> <%= submit_tag "OK", {:name => "submit", :class => "inputSubmit"} %> </div> </div> is ther any way to do that ? thanks a lot fyl -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Could you not use CSS to position the buttons in another order? For example, one of: div.submit div { position: relative; } /* you would need to define separate classes for the ok and cancel buttons */ div.submit div .okButton { position: absolute; top: 0px; left: 0px; } div.submit div .cancelButton { position: absolute; top: 0px; left: 100px; /* or however wide your buttons are */ } Alternatively: div.submit div { float: right; } I haven''t tested either of these, but you should be able to do something similar to swap the button order. Cheers, Roland On Jan 8, 2:06 pm, Kad Kerforn <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I am using two submit buttons within my form without any problem, as > specified (http://www.railsdiary.com/diary/two_submit_buttons) > > BUT when the user doesn''t hit a button and just hit ENTER, I got the > first button submit in my controller which unfortunatly is the Cancel > button in my view... > > Yes, if I change the button position (OK first in html..) I get it.. but > I''d like to keep my display as required by the users... Cancel button > must come before OK button.... > > <div class="submit"> > <div> > <%= submit_tag "Cancel", {:name => "submit", :class => > "inputSubmit" }%> > <%= submit_tag "OK»", {:name => "submit", :class => "inputSubmit"} > %> > </div> > </div> > > is ther any way to do that ? > > thanks a lot fyl > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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: http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1 http://www.htmlcodetutorial.com/forms/_INPUT_TABINDEX.html David Kad Kerforn wrote:> > I am using two submit buttons within my form without any problem, as > specified (http://www.railsdiary.com/diary/two_submit_buttons) > > BUT when the user doesn''t hit a button and just hit ENTER, I got the > first button submit in my controller which unfortunatly is the Cancel > button in my view... > > Yes, if I change the button position (OK first in html..) I get it.. but > I''d like to keep my display as required by the users... Cancel button > must come before OK button.... > > > <div class="submit"> > <div> > <%= submit_tag "Cancel", {:name => "submit", :class => > "inputSubmit" }%> > <%= submit_tag "OK�", {:name => "submit", :class => "inputSubmit"} > %> > </div> > </div> > > is ther any way to do that ? > > thanks a lot fyl >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 %> thanks Oliver On Jan 11, 6:34 pm, David Schmidt <dav...-kdJrRYpCMe5Wk0Htik3J/w@public.gmane.org> wrote:> 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: > > http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1http://www.htmlcodetutorial.com/forms/_INPUT_TABINDEX.html > > David > > Kad Kerforn wrote: > > > I am using two submit buttons within my form without any problem, as > > specified (http://www.railsdiary.com/diary/two_submit_buttons) > > > BUT when the user doesn''t hit a button and just hit ENTER, I got the > > first button submit in my controller which unfortunatly is the Cancel > > button in my view... > > > Yes, if I change the button position (OK first in html..) I get it.. but > > I''d like to keep my display as required by the users... Cancel button > > must come before OK button.... > > > <div class="submit"> > > <div> > > <%= submit_tag "Cancel", {:name => "submit", :class => > > "inputSubmit" }%> > > <%= submit_tag "OK?", {:name => "submit", :class => "inputSubmit"} > > %> > > </div> > > </div> > > > is ther any way to do that ? > > > thanks a lot fyl--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On 2/15/07, Oliver <fwang2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 %> > > thanks > > Oliver > > > On Jan 11, 6:34 pm, David Schmidt <dav...-kdJrRYpCMe5Wk0Htik3J/w@public.gmane.org> wrote: > > 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: > > > > http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1http://www.htmlcodetutorial.com/forms/_INPUT_TABINDEX.html > > > > David > > > > Kad Kerforn wrote: > > > > > I am using two submit buttons within my form without any problem, as > > > specified (http://www.railsdiary.com/diary/two_submit_buttons) > > > > > BUT when the user doesn''t hit a button and just hit ENTER, I got the > > > first button submit in my controller which unfortunatly is the Cancel > > > button in my view... > > > > > Yes, if I change the button position (OK first in html..) I get it.. but > > > I''d like to keep my display as required by the users... Cancel button > > > must come before OK button.... > > > > > <div class="submit"> > > > <div> > > > <%= submit_tag "Cancel", {:name => "submit", :class => > > > "inputSubmit" }%> > > > <%= submit_tag "OK?", {:name => "submit", :class => "inputSubmit"} > > > %> > > > </div> > > > </div> > > > > > is ther any way to do that ? > > > > > thanks a lot fyl > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. Oliver On Feb 15, 4:04 pm, "Chris Hall" <christopher.k.h...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. > > On 2/15/07, Oliver <fwa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 %> > > > thanks > > > Oliver > > > On Jan 11, 6:34 pm, David Schmidt <dav...-kdJrRYpCMe5Wk0Htik3J/w@public.gmane.org> wrote: > > > 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: > > > >http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1http://www.ht... > > > > David > > > > Kad Kerforn wrote: > > > > > I am using two submit buttons within my form without any problem, as > > > > specified (http://www.railsdiary.com/diary/two_submit_buttons) > > > > > BUT when the user doesn''t hit a button and just hit ENTER, I got the > > > > first button submit in my controller which unfortunatly is the Cancel > > > > button in my view... > > > > > Yes, if I change the button position (OK first in html..) I get it.. but > > > > I''d like to keep my display as required by the users... Cancel button > > > > must come before OK button.... > > > > > <div class="submit"> > > > > <div> > > > > <%= submit_tag "Cancel", {:name => "submit", :class => > > > > "inputSubmit" }%> > > > > <%= submit_tag "OK?", {:name => "submit", :class => "inputSubmit"} > > > > %> > > > > </div> > > > > </div> > > > > > is ther any way to do that ? > > > > > thanks a lot fyl--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 %< On 2/15/07, Oliver <fwang2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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. > > Oliver > > On Feb 15, 4:04 pm, "Chris Hall" <christopher.k.h...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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. > > > > On 2/15/07, Oliver <fwa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 %> > > > > > thanks > > > > > Oliver > > > > > On Jan 11, 6:34 pm, David Schmidt <dav...-kdJrRYpCMe5Wk0Htik3J/w@public.gmane.org> wrote: > > > > 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: > > > > > >http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1http://www.ht... > > > > > > David > > > > > > Kad Kerforn wrote: > > > > > > > I am using two submit buttons within my form without any problem, as > > > > > specified (http://www.railsdiary.com/diary/two_submit_buttons) > > > > > > > BUT when the user doesn''t hit a button and just hit ENTER, I got the > > > > > first button submit in my controller which unfortunatly is the Cancel > > > > > button in my view... > > > > > > > Yes, if I change the button position (OK first in html..) I get it.. but > > > > > I''d like to keep my display as required by the users... Cancel button > > > > > must come before OK button.... > > > > > > > <div class="submit"> > > > > > <div> > > > > > <%= submit_tag "Cancel", {:name => "submit", :class => > > > > > "inputSubmit" }%> > > > > > <%= submit_tag "OK?", {:name => "submit", :class => "inputSubmit"} > > > > > %> > > > > > </div> > > > > > </div> > > > > > > > is ther any way to do that ? > > > > > > > thanks a lot fyl > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---