0
I’m doing a shopping simulation page.
I already have the product loop in PHP, now I need to calculate each product by quantity.
Here the HMTL:
<td width="140"><?= $produto_nome; ?></td>
<td width="160"><?= $produto_descricao; ?></td>
<td width="60"><?= $produto_tamanho; ?></td>
<td width="90">
<input type="number" id="qtd" name="qtd" min="1" max="99" onChange="MudaLabel('total', this.value)">
<a href="#">remover</a>
</td>
<td width="120"><span id="preco"><?= $produto_preco; ?></span></td>
<td width="90">
<label id="total"></label>
</td>
Here the jQuery:
function MudaLabel(LabelID, value){
var Preco = $('#preco').text();
var Total = value * Preco; //valor de exemplo
document.getElementById(LabelID).innerHTML = Total;
Now think of it as a looping. How do I make each table of this to be individually chalked.
This way I did, when I change the amount of other products changes only the value of the first.
Perfect, Philip! It was more a logical question even, that I had not thought. Saved me! Thank you very much!
– Carlos Henrique