Adding text to calculations

  • airdat
    Asked on March 15, 2016 at 6:19 AM

    Hi,

     

    I need to add some text the calculation field on a form so that is shows the user what they have scored for each section out of a possible max. However when I add the "out of" text it seems to corrupt the final calculation. I have an example of what I mean here

    https://form.jotform.com/60743030588960

    On loading the form the Total already has 300 out of 300 but no fields have been selected. Selecting fields just corrupts the totl further.

     

    Many thanks

  • Boris
    Replied on March 15, 2016 at 9:29 AM

    If you add text into one calculation field, that calculation field cannot be used in other form calculation fields anymore - or it will cause the conflicts of the type you have experienced. There are two workarounds to achieve what you are after, you can choose any one of them you may prefer.

    1. The easiest method is that you do not add text into section calculations. If you want to indicate out of how many possible points the section total was calculated, you may want to:

    a) either put it into the label of the section calculation field:

    Adding text to calculations Image 1 Screenshot 50

    or b) hide the calculation field and use a regular Text field that will display the calculated amount instead:

    Adding text to calculations Image 2 Screenshot 61

    In the above image, {section15} is the name tag of the section 1 calculation field. You can see the correct name tag to use within your custom message by following this guide:

    http://www.jotform.com/help/146-How-to-find-Field-IDs-Names

    By using a Text field to display the message, you even have some nice styling options available, such as making the text bold, or coloring the actual total that the user scored in this section:

    Adding text to calculations Image 3 Screenshot 72

    The above would be the recommended way to set up the section scores.

    2. If you still want to add text directly into your section calculations, then you should set up your total calculation not to calculate from the section calculations, but from the fields within the sections themselves.

    In other words, if calculation for section 1 calculates as A1 + B1, and section 2 calculation calculates as A2 + B2, you would use total calculation such as this one:

    (A1 + B1) + (A2 + B2)

    Currently, your total calculation is set to calculate the section calculations that have text, which is causing the conflict because in practice it results in this:

    (A1 + B1 out of 300) + (A2 + B2 out of 300)

    So in case you want to have text directly within the section calculations, for the total calculation, you would be using only the fields marked in green in the following screenshot:

    Adding text to calculations Image 4 Screenshot 83

    If you need any further assistance, please let us know.

  • airdat
    Replied on March 15, 2016 at 9:39 AM

    I see the issue now and will go with one of your solutions. Many thanks for the speedy response Boris. 

  • Kiran Support Team Lead
    Replied on March 15, 2016 at 10:42 AM

    Great! Glad to see that you have identified the issue on the form. Please do not hesitate to get in touch with us if you need any further assistance. We will be happy to help. 

    Thank you for using JotForm!!