How can I calculate the total cost in my form?

  • DefenderAmmo
    Asked on February 1, 2017 at 9: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.

     

    Krissy

  • KadeJM
    Replied on February 1, 2017 at 9:45 AM

    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.

     

  • KadeJM
    Replied on February 1, 2017 at 9:59 AM

    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:

    https://www.jotform.com/help/259-How-to-Perform-Form-Calculation-Using-a-Widget

    Also, it might be a good idea to set up calculation values for your fields to make it more effective:

    https://www.jotform.com/help/301-How-to-Assign-Calculation-Value 

  • DefenderAmmo
    Replied on February 1, 2017 at 10:40 AM

    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. How can I calculate the total cost in my form? Image 1 Screenshot 20

  • candy
    Replied on February 1, 2017 at 10:58 AM

    Dear Krissy,

    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:

    How can I calculate the total cost in my form? Image 1 Screenshot 30

    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:

    How can I calculate the total cost in my form? Image 2 Screenshot 41

     

    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.

  • DefenderAmmo
    Replied on February 1, 2017 at 1:15 PM

    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?

  • candy
    Replied on February 1, 2017 at 1:55 PM

    Hello,

    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:

    How can I calculate the total cost in my form? Image 1 Screenshot 40

    How can I calculate the total cost in my form? Image 2 Screenshot 51

     

    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:

    How can I calculate the total cost in my form? Image 3 Screenshot 62

     

    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.

    Thank you.

     

     

  • DefenderAmmo
    Replied on February 2, 2017 at 1:27 PM

    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?

  • Kevin Support Team Lead
    Replied on February 2, 2017 at 2:53 PM

    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. 

    How can I calculate the total cost in my form? Image 1 Screenshot 40

    You may also refer to the info right below the number pad in the calculation widge, there you will find how each element looks: 

    How can I calculate the total cost in my form? Image 2 Screenshot 51

    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.

    How can I calculate the total cost in my form? Image 3 Screenshot 62

    Hope this helps.