Hey,
I need some help, I am trying to make this code work below. I am trying to enter details into each of the 4 boxes, the result of input 1 and 2 would then be added to the result of input 3 and 4, then displayed as “total”
Input 1 * (Input 2 *Number) + Input 3 * (Input 4 *Number)
// For full API documentation, including code examples, visit https://wix.to/94BuAAs
$w.onReady(() => {
let price1 = 0;
let price2 = 0;
let price3 = 0;
let price4 = 0;
$w("#input1, #input2, #input3, #input4").onChange(event => {
let target = event.target.id;
let newVal = Number($w("#" + target).value);
target === "input1" ? price1 = 1 * newVal : price2 = 1 * newVal : price3 = 1 * newVal : price4 = 1 * newVal;
$w("#total").text = (price1 + price2 + price3 + price4).toLocaleString();
})
})