0
I have a form with several inputs number, each input has an attribute called product_val
that contain a value.
I need that when changing the content of an input (change), a given function captures all inputs of the form, takes the value of the attribute and multiplies by its value, after obtaining this result, sum all in a variable.
Input class: order_input_qnt
Sum result: order_total_price
In the jsfiddle
jQuery(function ($)
{
$('.order_input_qnt').on('change',function()
{
$(".order_total_price").html("...");
var sum = 0;
$(".order_input_qnt").each(function()
{
if ($(".order_input_qnt").val().length > 0) {
var valor = parseFloat($(".order_input_qnt").attr("product_val")) * parseFloat($(".order_input_qnt").val());
sum += valor;
}
});
$(".order_total_price").html(sum.toFixed(2));
});
});
I could not interpret the question. Could you describe the operations step by step? Ex.: 1 - Sum the value of all fields, 2 - Multiply the result.... etc....
– Marcelo Vieira
@Marcelovieira edited the post
– sNniffer
Is that so? https://jsfiddle.net/w7ze1m68/3/
– Valdeir Psr