Onclick in submit_tag?

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.

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.

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