cómo usar jquery .each para qyt + precio = suma total, estoy usando javascript pero tengo un error si lo lleno con cualquier color y edito la entrada de otro color, total_sum_value incorrecto
<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; } }estoy usando ajax para agregar a la tabla