1
I am new to web programming and Rails and have the following question:
I have a view that displays a food list and a field to fill with the amount of grams I want from each food. I’d like to exhibit a text_field_tag
for every element of the list I own, something like:
<% @alimentos.each do |alimento| %>
<%= text_field_tag :alimento %>
<%= label_tag(:alimento, "#{alimento.nome}: #{alimento.preco} reais a grama" )%>
<% end %>`
However, I would like to send the amount you put in the fields to a javascript function that multiplies the price by the value I entered and then display the calculated total value in the view.
Unfortunately I have no idea how to do this: How to create a text_field_tag
with a different symbol for each iteration of each? How to send the values that fill the fields to the javascript function, where to create the javascript function and how to display the function calculation result?
Could someone help me?