Señores Buenas con todos… Por favor necesito ayuda con este código, estoy tratando de calcular el resultado una vez ingresado la cantidad y el precio con simple_form, y automáticamente debe salir el resultado total, sin que haya presionado grabar o actualizar, y también sin la necesidad de usar código javascript, u otra plataforma. quiero que salga en el mismo archivo html ya con el embedido de ruby on rails. me sale solamente cero, no lo llama a los parámetros cantidad y precio , adjunto el código:
-
<%= simple_form_for(@ticket) do |f| %>
-
<%= f.error_notification %>
-
<div class="form-inputs">
-
<%= f.input :fecha %>
-
<%= f.input :impuesto, :input_html => { value: '18.00'} %>
-
<%= f.association :customer, label_method: "#{:nombre}", value_method: :id, prompt: "Debes buscar la empresa" %>
-
<%= f.association :status %>
-
<div>
-
<table id="items">
-
<tr>
-
<th class="text-center" width="60px">ITEM</th>
-
<th class="text-center" width="160px">CODIGO</th>
-
<th class="text-center" width="225px">DESCRIPCION</th>
-
<th class="text-center" width="100px">CANTIDAD</th>
-
<th class="text-center" width="110px">PRECIO</th>
-
<th class="text-center" width="150px">TOTAL <%= @empresa.moneda1 %></th>
-
<th></th>
-
</tr>
-
</table>
-
<%= simple_nested_form_for @ticket, :wrapper => false do |g| %>
-
<table id="detail_tickets">
-
<%= g.simple_fields_for :detail_tickets do |p| %>
-
<tr class="fields">
-
<th align="center" width="60px" class="text-center"><%= p.input :item, label: false %></th>
-
<th align="center" width="160px"><%= p.input :code, label: false %></th>
-
<th align="center" width="225px" class="description"><%= p.input :description, label: false, :input_html => {:rows => 3} %></th>
-
<th align="center" width="100px" class="text-center"><%= p.input :cantidad, label: false %></th>
-
<th align="center" width="110px" class="text-right"><%= p.input :price, label: false %></th>
-
<% @total_price = params[:cantidad].to_s.to_d * params[:price].to_s.to_d %>
-
<th align="right" width="150px" class="text-right"><%= @total_price %></th>
-
<th align="center" width="63px" class="text-center"><%= p.link_to_remove "", class: "btn btn-danger fa fa-trash" %></th>
-
</tr>
-
<% end %>
-
</table>
-
<table id="items">
-
<tr>
-
<th width="700px"></th>
-
<th class="text-center" width="110px">VALOR DE VENTA : </th>
-
<th class="text-center" width="150px"></th>
-
</tr>
-
<tr>
-
<th width="700px"></th>
-
<th class="text-center" width="110px">I.G.V. : </th>
-
<th class="text-center" width="150px"></th>
-
</tr>
-
<tr>
-
<th width="700px"></th>
-
<th class="text-center" width="110px">TOTAL : </th>
-
<th class="text-center" width="150px"></th>
-
</tr>
-
</table>
-
<br>
-
<br>
-
<p><%= g.link_to_add "Adicionar Producto", :detail_tickets, :data => { :target => "#detail_tickets" }, class: "btn btn-primary" %></p>
-
-
<%= f.button :submit %>
-
<% end %>
-
<% end %>
``