Calculating price based on user input

Hi Guys,

My problem is, when a user inputs all the field, I want to calculate the user input into a text field that’ll show how much a user has to pay he uses clean energy when he selects from the dropdown fields. Here’s my calculation formula:
Kilowatt usage x price + admin fee (.01 x kilowatt usage) = total price
Here’s sample screenshot of the input fields:


The user inputs their choices then a corresponding price is shown in the price input


The user then inputs how much power they consume and the Total field will be updated accordingly by using the said formula:
Kilowatt usage x price + admin fee (.01 x kilowatt usage) = total price

I am new to wix and have very minimal jquery skills, so any detailed explanation would really be appreciated.

Many thanks,
Kev

Hey
Use Javascript to calculate the values you get from the elements on your page. If you get a value from a text input you will need to convertkit it to a number first using Number(value) to be able to calculate.

You can learn more how to calculate in basic Javascript here

Then you set the calculate value to your element and if that is a text input which has text as field type or a text element you need to make it a string before you set it to your element.

You do that by value.toString() and then any number will be converted to a string.

Please add your code here to get more guidance

Hi Andreas, thanks for the reply! Will try to implement and post an update here. Keep you posted