I set up a JavaScript program using jQuery to change the user input values at various form field.
$(document).ready(function(){
$("#billAmt").keyup(function(){
var a = $("#billAmt").val();
var b = a*3/100;
var d = "<%= current_user.balance %>";
var c = d - b;
$("#cashBack").val(b);
$("#total").val(c);
});
});
This JavaScript code is inside the form_tag and I would like to pass #cashBack to hidden field.
I did like:
<%= hidden_field_tag :cashBack, nil, :id => "cashBack", :value => ''%>
When I submit the form, params[:cashBack] is empty. So, how do I pass the value and change every time I change the value.
console.log()