Hi, I have a submit_tag in test.rhtml ... <% submit_tag ("Save") %> I want to add the following popup box onclick: "Are you sure?" Yes No where "Yes" & "No" are buttons. If "Yes" is pressed, I go to another controller with parameters else I stay with test.rhtml. How do I do it? Thx, Ram. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
the easy way is probably to have something like <%= submit_tag "Save", :onclick => "return confirm(''Are you sure?'')" %> assuming your form action already points to the place you want to go to on "OK", else you''ll have to use more javascript to change the form''s action. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ram wrote:> I have a submit_tag in test.rhtml > I want to add the following popup box onclick: > > "Are you sure?" >you can just use the :confirm param at the form_tag. You only have to provide the string for the confirm box and that''s it (i.e. :confirm=>''Are you sure?'') That will display the standard javascript confirm. In case you want a nicer popup then you should implement yours by using a javscript function returning true/false and to call it you can just pass the :onsubmit param to the form. regards, j --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---