What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.
At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.
We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.
How can I calculate the total cost in my form?Asked by DefenderAmmo on February 01, 2017 at 09:25 AM
I've read calculation threads repeatedly but I can't find any information on how to do what I'm trying to do. I've also tried the "trial and error" method to no avail. Please help me make this thing work.
I'm trying to calculate the total cost depending on the number in the box. So the calculation would be the (field name) x ($price) + (field 2) x ($price2) and the total of those inserted in the total cost box. But it doesn't work.
What am I missing?
Thanks for the help.
I see you're having some trouble getting your form calculation to calculate and put the calculation into the total cost field.
Please allow us a bit of time to look this over to see what is happening here and we will respond to you again as soon as possible.
I am seeing a few problems here namely the calculation field has nothing in it so that's the main reason why it's not outputting anything at all.
Looking at your form more I'm not quite sure I understand which field name and price you are attempting to multiple by another field name and price as you have several.
Were you attempting to multiple the item count and|or mg by the cost + additional products similar if more than one is chosen? Pardon, but I am trying to understand how you're needing this to work a little better.
Doing so should be possible but I would suggest starting off small first and these guides can help:
Also, it might be a good idea to set up calculation values for your fields to make it more effective:
I'm not sure what you mean that the calculation doesn't have anything in it. Here's what I'm trying to do. When someone enters a number in the field, I would like to multiply that number by the price of the item. Each item has a different price and the total should be calculated at the end.
I've cloned your form on my side in order to test it.
First of all, I have seen that you have set a form calculation widget in order to calculate a value. However, you used conditional calculation. This configuration is not correct.
Your form calculation widget has wrong configurations as you can see the screenshot below:
I recommend you to delete the conditional calculations and set the right calculation to the Form Calculation widget as you can see the screenshot below:
Please check the following guide for detailed information regarding Form Calculation widget: https://www.jotform.com/help/259-How-to-Perform-Form-Calculation-Using-a-Widget
If you need any assistance, let us know.
Thanks in advance.
My head is going to explode. I just followed your directions above, but the calculation is still coming out crazy. Please advise. What am I entering incorrectly?
I've investigated your form again on your side.
Firstly, as I have seen you have textbox fields for numeric values. You need to set them as "numeric" and give the first value as 0 as you can see the screenshots below:
Secondly, your calculation widget recognized the ()+* characters as normal letters(strings). You need to set them as "number fields" by clicking on them as you can see the screenshot below:
After setting, please check your calculation one more time if it will calculate the correct value or not. Because I think you have put a wrong field to the calculation widget.
The first calculation widget calculates the value correctly but there is a field is wrong in the second one.
Please check again.
I changed my fields to "numeric", but I'm not sure what you mean about the wrong field being in the calculation. What needs to change now?
My colleague was referring to the elements in your calculation, all of them must be set as numeric since you're doing mathematical operations, otherwise it will not work.
You may also refer to the info right below the number pad in the calculation widge, there you will find how each element looks:
Also, I would suggest you to set the default value as 0 for all your text box fields, an empty field is interpreted as "NaN" in the calculation code so this is why it does not work currently in your form.
Setting a default value to 0 will help to avoid this conflict and your calculation should be correct.
Hope this helps.