I have a view with a simple_form and an input called priority. Before the submit button I have Your request is going to cost $X.
My X cost is going to change accordingly to what the user select in the priority input.
The thing is I need to get the priority input from the user to call a Ruby service, get the result and add it to the Your request is going to cost $X.
What I have in my view is something like:
= f.input :priority
p Your request is going to cost <strong id="selected-priority">0</strong>.
= f.submit "Send",
javascript:
$('#priority').on("change", function(e) {
var priorityInput = $(this).val(); # this is going to return something like "EMERGENCY"
var totalInDollars = #{CalculateAmount.call(priority: ??)};
$('#selected-priority').text("$" + totalInDollars);
}).change();
This is all working but I have no idea how to add the priorityInput js variable to my service call.
Could someone help? Tks!