Calculate total from database & user input

Dear Wix People

I have a database which in a column lists a price for an “adult” and in another column a price for a “child”.

I want to use a User Input box so client can choose No. of Adults | No. of Children.

Then I want a “Total Cost” to be listed in a Repeater.

Is there a tutorial? Any Ideas?

Thanks

Hugh

Hi Hugh ,

For making calculations with some data from the database, first you should get the value from the database , then from user input, do the calculations and finally the result you can place it where ever you want. Few things you should know to help you :
1- Get the current value of the (adult OR Child) form the dataset - Learn more
so, it should look something like this :

let adultPrice= $w("#myDataset").getCurrentItem().adult;

2- get the user input value,

let numberOfAdults = $w("#userInput").value;
then do the calculations and store it in a variable and you can use it where ever you want : 

let result = adultPrice * numberOfAdults ; //

hope this covers all you wanted to know!
Best,

Mustafa