how do you make a sum or a multiplication on wix code

I am trying to make additions or multiplications on my web site using wix code. I am an absolute beginner in this using infos got on youtube but I got error on the value part of the code I did (see below). Could you please show me what to do to make this code work!

// For full API documentation, including code examples, visit http://wix.to/94BuAAs

$w.onReady( function () {
//#labaguettefrancaise

});

let kgdefarine = Number($w(“#kgdefarine”),value);
let Qparpain = Number($w(“#Qparpain”),value);
let nbredepaindropdown = Number($w(“#nbredepaindropdown”),value); {
// Add
Qparpain = kgdefarine / 4.86;
console.log(Qparpain);
}

Thank in advance for all the help

Stanley

1 Like

You need a function such as a Button’s onClick event to do the calculation.

Below I have a Button with an id calculate

export function calculate_click(event) {
   let value = Number($w('#input1').value) * Number($w("#input2").value);
   console.log(value); 
}

The above function multiplies #input1 & #input2 and produces the result in the console.

Hi shan

Thanks for the help. I followed your advice & I have no more program mistakes as it seems. but my problem that the result of the calculation doesn’t appear on in my preview under 'Q de pâte/pain. See what I did on the picture I included. What an I still missing. Could you help me with this!


Thanks in advance for all your help

Stanley

Where is your button?

Select your button and screenshot the page to show the button’s properties panel

Sorry shan,
I do not follow you. as I said I am a total beginner in this, so you need to give me explanations for “dummies” if I can say so.
What I can tell you is that I gave an specific ID to each button
the 80 is dropdown1/#dropdown1
the 4 is kgdepate1/#kgdepate1
the button after 4 is qdepate1/#qdepate1
what I want is the it calculates me 4/80 & puts the result in #qdepate1 automatically which it doesn’t do.
reason can be that my button settings might be wrong or that my program has a mistake in it or is missing something make it work.
This is what I would love you to guide me though.

I thank you in advance for your helping me solving this problem which surely is an easy thing in the programing world but at this point it is a big issue.

Best regard

Stanley

you seem to be using commas in front “,value” instead of “.value”