how to using jquery .each for qyt + price = sum total , im using javascript but have a bug if i fill with any colom and i edit input antoher colom, total_sum_value wrong
<script>
function sum(x) {
var qty = $("#product_qty" + x).val();
var price = $("#p_price" + x).val();
var productx = 0;
if (qty == "") {
$("#product_qty").val("");
// alert('Qty Request');
} else {
var product_tot = parseInt(qty) * parseInt(price);
document.getElementById("product_tot" + x).value = product_tot;
for (let i = 1; i <= x; i++) {
var totalhit = $("#product_tot" + i).val();
productx = parseInt(productx) + parseInt(totalhit);
}
document.getElementById("total_sum_value").value = productx;
}
}
im using ajax for append for the table