Maybe a dumb question but I can't find an answer to it. Still learning :)
I have a form with two input fields with the same class name. I'm trying to grab both values and calculate the square metres and price. Grabbing the input values isn't a problem but "storing" the values in variable is.
To calculate the price I need to do something like L x W x Price. But how can I create the two Length and Width variable when using the .each() function (names can be different offcourse)? Is this a good approach?
Adding ID's or classnames isn't a option since everything is created dynamically!
So what I have is this:
function update_amounts() {
var price = '129';
var sum = 0;
$('#product_configure_form .product-configure-custom-option input').each(function(){
var value = parseFloat($(this).val()) / 100;
});
// Here I need to do something like
sum = value1 * value2 * price
//////////////////////////////////
var sumsum = sum.toString().replace(/\./g, ',');
$('.price-wrap .price').text('€ ' + sumsum);
}
$(document).ready(function(){
$("#product_configure_form").on("change", ".product-configure-custom-option input", update_amounts);
});
idto both inputs instead of usingclassif you want to get the values like that. Also, where does your two variablesvalue1andvalue2gets declared ?