hello friends
i have a jquery function who calculate a total of form field in real time (live), the value of field is data from DB table .. it work fine i have add php loop to show all data in table but the jquery function calculate only the first line.
i would like to calculate all. he is the form
<form name="panierform" method="post" action="">
<table width="80%" border="2">
<?php do { ?>
<tr>
<td><label for="article"></label>
<input type="text" name="article" id="article" value="<?php echo $row_Recordset1['article']; ?>">
</td>
<td><label for="prix"></label>
<input name="prix" type="text" id="prix" value="<?php echo $row_Recordset1['prix']; ?>"></td>
<td><label for="quantity"></label>
<input name="quantity" type="number" id="quantity" value="1"></td>
<td>
<label for="ptotal"></label>
<input type="text" name="ptotal" id="ptotal" value=""></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
for exemple if i have i have 5 data in my table the php loop will show 5 data but the ptotal field value is from jquery function it get only the first and all other are empty.
here the jquery code :
<script type="text/javascript">
function calculatePtotal()
{
var value = parseFloat($('#prix').val());
var quantity = parseFloat($("#quantity").val());
var shipping = parseFloat($("#shipping").val());
var ptotal = (value * quantity);
$("#ptotal").val(parseFloat(ptotal).toFixed(2));
}
$("#quantity, #shipping").change(function() {
calculatePtotal();
});
calculatePtotal();
</script>