JSFiddle - React, Tailwind, and code Playground
HTML
Product ID: 1065
<input type="text" class="text cart_qty" id="Form_OrderForm_Product-1065-qty" name="Product[1065][qty]" value="1" />
<input type="text" class="text prod_id" id="Form_OrderForm_prod_1065" name="prod_1065" value="1000" />
<input class="hidden" type="hidden" id="Form_OrderForm_hidden_1065" name="hidden_1065" value="1.45" />
Line total: <span id='Product_1065_Line' class='cart_price_line'>1.45</span>
<hr />
Product ID: 1337
<input type="text" class="text cart_qty" id="Form_OrderForm_Product-1337-qty" name="Product[1337][qty]" value="1" />
<input type="text" class="text prod_id" id="Form_OrderForm_prod_1337" name="prod_1337" value="500" />
<input class="hidden" type="hidden" id="Form_OrderForm_hidden_1337" name="hidden_1337" value="1.45" />
Line total: <span id='Product_1337_Line' class='cart_price_line'>1.45</span>
<hr />
Total: <span id="total_price_curr"></span>
JavaScript
$("document").ready(function() {
$('.cart_qty').keyup(function(){
var $thetotal=0;
$('input.cart_qty').each(function(index) {
$theqty=$(this).val();
$thenextindex=$("input").index(this) + 2;
$theprice=$("input:eq("+$thenextindex+")").val();
$thelinetotal=$theqty * $theprice;
$thetotal=$thetotal + $thelinetotal;
var product_id = $(this).attr("id").split("-")[1];
$("#Product_" + product_id + "_Line").html($thelinetotal);
});
$("#total_price_curr").html($thetotal);
$("#Form_OrderForm_totalHidden").val($thetotal);
});
});