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's 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's 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 be individually calculated.
This way I did, when I change the amount of other products changes only the value of the first.