-1
var prodAdd = false;
$(".id").each(function(index, value) {
if ($(value).val() == vId) {
Swal({
type: 'info',
html: '<h5>Produto ja adicionado!</h5>',
background: 'radial-gradient(#f1f1f1,LightGray)',
showConfirmButton: true,
})
$('#pqnt').val(vQnt + 1)
prodAdd = true;
}
});
if (!prodAdd) {
var cont=0;
var linha = '<tr class="selected" id="linha'+cont+'">'+
'<td>'+
'<input class="id" type="hidden" name="idproduto[]" value="'+vId+'">'+vProduto+
'</td>'+
'<td>'+
'<input id="preco" type="text" class="form-control text-right" name="preco[]" value="'+vPreco+'" onblur="multiplicar();" onblur="formatar();">'+
'</td>'+
'<td>'+
'<input id="pqnt" type="text" class="form-control text-center" name="qnt[]" value="'+vQnt+'"><span class="vlr">'+
'</td>'+
'<td>'+
'<input style="text-align: right;" id="subtotal" class="form-control subtotal" type="hidden" value="'+vTotal+'" readonly onblur="calcular();">'+
'<input style="text-align: right;" type="text" class="form-control subtotalT" id="subtotalT" name="subtotal[]" value="'+numberToReal(vTotal)+'" readonly>'+
'</td>'+
'<td class="text-center">'+
'<a style="cursor:pointer" onclick="deleteRow(this)" class="glyphicon glyphicon-trash"></a>'+
'</td>'+
' </tr>'
cont++;
$('#mytbody').append(linha);
contItem();
calcular();
$(".subtotal").each(function() {
$(this).blur(function(){
calcular();
});
});
}
}
<table id="tab" class="table table-striped" style="width: 100%;table-layout:fixed">
<thead>
<tr>
<th id="tab_cab" style="width:15%">Produto</th>
<th id="tab_cab" style="width: 8%">Preço</th>
<th id="tab_cab" style="width: 7%">Qnt</th>
<th id="tab_cab" style="width: 9%">SubTotal</th>
<th id="tab_cab" style="width: 3%;border-left:solid 1px">...</th>
</tr>
</thead>
<tbody id="mytbody">
</tbody>
</table>
Good afternoon, everyone.
I’m making a pdv screen and would like that when I add the same item more than once, it just increment in quantity and vice versa, when I remove it, it removes in quantity one by one.
edit the question and enter the code to make it easier to help you.
– OtavioCapel
thanks for the return Otaviocapel . See my code above. However it increments once and for.
– frodrigues