Hi community! I wanted to know if there was any way to calculate (with a formula) something from an input on the website (a form, for instance) and to display the result on the same page or on another.
My goal is to create a simulator. The user enters the amount of their electrical bills, and the website displays their consumption (in kWh), some equivalencies (in TV hours, lighting hours, ect.) and if its consumption is normal compared to the average.
This would be the input pannel :
And this would be the output page with the calculated values :
Do you think that this would be possible using code (Python, Javascript, HTML…), Wix apps or anything that could work ? I am not very good at coding (and even less for web code)
Thank you for helping.
Killian
(Sorry for the double post on Velo and Wix Forum, I didn’t know where to post this)
Of course it’s possible.
Try first to reconstruct “cette simple example”…
$w.onReady(()=>{
$w('#myButton').onClick(()=>{
commencer_Calculation(); // ca c'est ton function du calculation
});
});
function commencer_Calculation() {
let variable_A = $w('#inputField1')
let variable_B = $w('#inputField2')
myResult = variable_A + variableB
console.log(myResult)
}
You will need 2x → “input-fields”, 1x → button and the shown code above.
Try it out and see the result in the → CONSOLE. Where to find the CONSOLE?
Google-Chrome —> Press F-12 and navigate to CONSOLE.
Wix-Editor-Preview-Mode: On the bottom of the screen you will find the console-logs.
Now you should understand how to create your own calculation-functions.
Now it’s your turn, expand and modify the code by your own needs.
Of course there are also other how you could programm calculations, for example by using a → “RETURN-FUNCTION”.
An example for a RETURN-FUNCTION you will find here…
https://russian-dima.wixsite.com/meinewebsite/simple-return-function
Good luck and happy coding. 