0
Good afternoon,
Access this site: conepa.agenciaweblab.com.br/inscriptions Guys, I’m having a little problem with my stroller system, I am able to multiply the value with the amount of each loop, however I am not making the loop of the cart with javascript, I am doing with php, and I need to add the values of the subtotals, I would like some solution. Main fields:
<td class="price-col" id="preco_<?= $list_cart->post_id; ?>" data-valor="<?= $list_cart->post_valor; ?>"><?= $list_cart->post_valor; ?></td>
<td class="quantity-col">
<input type="number" onChange="Multiplica(<?= $list_cart->post_id; ?>)" class="form-control qtd_<?= $list_cart->post_id; ?>" <?= $disabled; ?> min="1" max="<?= $list_cart->post_quantidade; ?>" placeholder="0" required="">
and now jquery:
function Multiplica(id) {
var valor = $('#preco_' + id).text();
var quantidade = $('.qtd_' + id).val();
var total = valor * quantidade;
document.getElementById('sub_' + id).innerHTML = number_format(total, '2', ',', '.');
var totals = 0;
$('#preco_' + id).each(function () {
totals += (valor * quantidade);
});
$("#totalSoma").text(totals);
}
someone to help? just need the total sum, what I did, did not have much success.
Where is the field with id
totalSoma
?– Juven_v
is just a span, out of the loop
– Alisson Maciel