Trying to make a custom :confirm message for a rails form that returns data from the submitted form--not just a static string.
<% form_for @foo do |f| -%>
<% f.text_field :number_of_bars -%>
<% f.submit :confirm => Are you really sure you want to use ##number_of_bars## bars? -%>
The idea is if the user puts in the number 3 in the number of bars text field the confirm message would show up like this: "Are you really sure you want to use 3 bars?"
Any ideas how to do this?
Trying to make a custom :confirm message for a rails form that returns data from the submitted form--not just a static string.
<% form_for @foo do |f| -%>
<% f.text_field :number_of_bars -%>
<% f.submit :confirm => Are you really sure you want to use ##number_of_bars## bars? -%>
The idea is if the user puts in the number 3 in the number of bars text field the confirm message would show up like this: "Are you really sure you want to use 3 bars?"
Any ideas how to do this?
Share Improve this question asked Mar 2, 2010 at 21:57 Kenji CroslandKenji Crosland 3,0346 gold badges34 silver badges43 bronze badges1 Answer
Reset to default 5Try this:
<%= f.submit :onclick => "return confirm('Are you really sure you want to use '+
document.getElementById('number_of_bars_id').value + '?' )" %>
Replace the number_of_bars_id
with the id of your field.
If you google a bit you will find a way for this to work with :confirm
.