1
I am with a problem that I am not able to solve I have a sales order screen where it has to do the quantity calculation X unitary value = (fill in the total value and add in the total order), how do I perform this calculation with jquery someone can help me follow part of the code below.
<table id="table-itens" class="table table-bordered table-hover table-striped">
<thead>
<tr class='info'><th colspan='6'>Itens do pedido de venda</th></tr>
<th class="th_codigo">Produto</th>
<th>Quantidade</th>
<th class="th_unitario">Valor Unit.</th>
<th class="th_total">Total</th>
</thead>
<tbody>
<tr id='line1' >
<td><input type='text' class='form-control input-sm codigo' value='29832' disabled /></td>
<td class='class_quant'> <input class='form-control input-sm codigo' type='text' name='ITEMARRAY[1][quantidade]' value='' id='qtn02' required/></td>
<td class='class_unit'> <input class='form-control input-sm vlr_unitario' type='tel' name='ITEMARRAY[1][vlr_unitario]' id='valor_unitario03' required /></td>
<td class='class_total'> <input class='form-control input-sm total' type='text' name='ITEMARRAY[1][total]' id='total02' readonly='readonly' /></td>
</tr>
<tr id='line2' >
<td><input type='text' class='form-control input-sm codigo' value='29835' disabled /></td>
<td class='class_quant'> <input class='form-control input-sm codigo' type='text' name='ITEMARRAY[3][quantidade]' value='' id='qtn02' required/></td>
<td class='class_unit'> <input class='form-control input-sm vlr_unitario' type='tel' name='ITEMARRAY[3][vlr_unitario]' id='valor_unitario03' required /></td>
<td class='class_total'> <input class='form-control input-sm total' type='text' name='ITEMARRAY[3][total]' id='total02' readonly='readonly' /></td>
</tr>
<tr class='info'>
<td colspan='3'></td>
<td class='total' colspan='2'><b>Total do pedido R$ : </b></td>
<td><div id='total'><span class='value_total'></span> </div></td>
</tr>
</tbody>
</table>
My jquery code looks like this, it is already calculating the values of the lines but I can not fill the total value of the line only passing over the field has some automatic way to do that when filling the quantity and the unitario value it already triggers the total of the line and sum in total?
$(window).ready(function () {
$('#table-itens tr td.class_quant').keyup(function () {
var quantidade = $(this).find('#qtn02').val();
$('#table-itens tr td.class_unit').keyup(function () {
valor_unitario = $(this).find('#valor_unitario03').val();
var total = (quantidade * valor_unitario);
$('#table-itens tr td.class_total').keyup(function () {
$(this).find('#total02').attr('value', total);
});
});
});
});
Thank you very much, it worked perfectly, man what you recommend me to improve knowledge in jquery some specific site?
– Maicon Fernando Stefene da Sil
@Check if the answer was useful for you mark it as accepted, so it can help other people with the same doubt. About the knowledge in jQuery I do not know indicate any specific site, I advise to see the documentation of jQuery itself, or rather, this site is very good to improve the knowledge. :)
– abfurlan
beauty, I’ll do it the problem now is the English I find the examples sometimes very simple but it was of great value, hug.
– Maicon Fernando Stefene da Sil