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:
1. <%= simple_form_for(@ticket) do |f| %>
2. <%= f.error_notification %>
3. <div class="form-inputs">
4. <%= f.input :fecha %>
5. <%= f.input :impuesto, :input_html => { value: '18.00'} %>
6. <%= f.association :customer, label_method: "#{:nombre}",
value_method: :id, prompt: "Debes buscar la empresa" %>
7. <%= f.association :status %>
8. <div>
9.
10. <table id="items">
11. <tr>
12. <th class="text-center" width="60px">ITEM</th>
13. <th class="text-center" width="160px">CODIGO</th>
14. <th class="text-center" width="225px">DESCRIPCION</th>
15. <th class="text-center" width="100px">CANTIDAD</th>
16. <th class="text-center" width="110px">PRECIO</th>
17. <th class="text-center" width="150px">TOTAL <%= @empresa.
moneda1 %></th>
18. <th></th>
19. </tr>
20. </table>
21. <%= simple_nested_form_for @ticket, :wrapper => false do |g| %>
22. <table id="detail_tickets">
23. <%= g.simple_fields_for :detail_tickets do |p| %>
24. <tr class="fields">
25. <th align="center" width="60px" class="text-center"><%= p.
input :item, label: false %></th>
26. <th align="center" width="160px"><%= p.input :code, label:
false %></th>
27. <th align="center" width="225px" class="description"><%= p.
input :description, label: false, :input_html => {:rows => 3} %></th>
28. <th align="center" width="100px" class="text-center"><%= p.
input :cantidad, label: false %></th>
29. <th align="center" width="110px" class="text-right"><%= p.
input :price, label: false %></th>
30. <% @total_price = params[:cantidad].to_s.to_d * params[:price]
.to_s.to_d %>
31. <th align="right" width="150px" class="text-right"><%=
@total_price %></th>
32. <th align="center" width="63px" class="text-center"><%= p.
link_to_remove "", class: "btn btn-danger fa fa-trash" %></th>
33. </tr>
34. <% end %>
35. </table>
36.
37. <table id="items">
38. <tr>
39. <th width="700px"></th>
40. <th class="text-center" width="110px">VALOR DE VENTA :
</th>
41. <th class="text-center" width="150px"></th>
42. </tr>
43.
44. <tr>
45. <th width="700px"></th>
46. <th class="text-center" width="110px">I.G.V. : </th>
47. <th class="text-center" width="150px"></th>
48. </tr>
49.
50. <tr>
51. <th width="700px"></th>
52. <th class="text-center" width="110px">TOTAL : </th>
53. <th class="text-center" width="150px"></th>
54. </tr>
55. </table>
56. <br>
57. <br>
58. <p><%= g.link_to_add "Adicionar Producto", :detail_tickets, :data
=> { :target => "#detail_tickets" }, class: "btn btn-primary" %></p>
59. <div class="form-actions">
60. <%= f.button :submit %>
61. </div>
62. <% end %>
63. <% end %>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/dc665592-0230-40df-9af7-058f5e8efd8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.