What i want is that every row should have its summation (row1=price x quantity) as the quantity changes the sum should be changing automatically(total=row1 + row2 +row3) so as the total of all rows.As it is am only able to achieve that with first row. Test my code here https://malawiclinic.000webhostapp.com/
<form class="form-inline">
<?php
$sqlm="SELECT * FROM tbl_wishlist ORDER BY id DESC ";
$resultmn=mysqli_query($db,$sqlm);
$fcount=mysqli_num_rows($resultmn);
if ($fcount>0) {
$countprice=0;
while($found = mysqli_fetch_array($resultmn)) {
$product = $found['product'];
$qty = $found['Quantity'];
$price = $found['price'];
echo "
<div class='form-group'>
<label for='exampleInputName2'>$product</label>
<input type='text' class='form-control' id='price'
value='$price'>
</div>
<div class='form-group'>
<input type='number' class='input-text form-control'
id='quantity' value='$qty'>
</div>
<label for='exampleInputName2'>$
<span id='result'></span>
</label>";
}
} ?>
</form>
<script type="text/javascript">
$(document).ready(function(){
$(document).on("input",".input-text", function(){
var x = document.getElementById("quantity").value;
var x1 = document.getElementById("price").value;
var total = x1 * x;
var totals = total.toLocaleString(undefined,
{maximumFractionDigits:2});
$("#result").html(totals);
$("#totals").html(totals);
});
});
</script>
ids for multiple elements.ids are supposed to be unique. Try to useclasses instead.