I have a form where a user can enter their monthly expenses...
<%= simple_form_for form do |f| %>
<%= f.input :income, label: "Income" %>
<%= f.input :overtime, label: "Overtime" %>
<%= f.input :bonuses, label: "Bonuses" %>
<%= f.input :commission, label: "Commissions" %>
<%= f.input :other_income, label: "Other Income" %>
*TOTAL HERE*
<% end %>
I would like to be able to add in a field where it says TOTAL HERE that dynamically adds up what the user has entered and then save that to the database. I played around with String interpolation but didn't have any luck. If anyone has any ideas on how I could do this I would be grateful.
Thanks
You can write a jQuery keyup
event for the textfields sum the all values and assign that into the total textfield as value. This will take care of you issue.