How Do I Get the Result of a Calculation to Be Formatted Like Currency, With Commas for Large Amounts?

  • fhpw
    Asked on March 21, 2015 at 6:48 PM

    I used the form calculation.  However, it does not seem to work on currency values.  I am asking users to provide expected expenses.  It will total only if decimal places are not used.  Even though I set the field to currency format  the $ or commas do not show.  For example, user has to input

    1000 + 200 = $1200

    Is there a way to have the currency fields show $ and commas and the calculating field include the comma?

     

    How Do I Get the Result of a Calculation to Be Formatted Like Currency, With Commas for Large Amounts? Image 1 Screenshot 20

  • abajan Jotform Support
    Replied on March 21, 2015 at 6:55 PM

    Although there's no way in the form builder to have commas shown, the amount displayed in the Total Expect(ed) Costs field can be made to more closely resemble currency if two decimal places are included for every result. This can be rectified as follows:

    1. Click the total field and then its wizard icon (button)

     How Do I Get the Result of a Calculation to Be Formatted Like Currency, With Commas for Large Amounts? Image 1 Screenshot 40


    2. Click Show Advanced Options:

    How Do I Get the Result of a Calculation to Be Formatted Like Currency, With Commas for Large Amounts? Image 2 Screenshot 51

    3. Check the box labelled Show empty decimal places.:

    How Do I Get the Result of a Calculation to Be Formatted Like Currency, With Commas for Large Amounts? Image 3 Screenshot 62


    4. Save the jotform

    Now, if you really need the decimals to be shown, the only workaround I can think of would be to get a copy of the form's full source, embed it into a web page of your own and then add a script to the same page. Some time ago I provided a script to do this for another user's form. Just let me know and I'll see what I can do for you.

    Thanks

  • fhpw
    Replied on March 21, 2015 at 7:20 PM

    That works great for the calculator field.  However, the text fields - even though marked as currency - does not allow decimal places or the $ sign if using the calculator.

  • abajan Jotform Support
    Replied on March 21, 2015 at 9:02 PM

    You know what? We actually have a widget named Masked Input that would format the inputs of the two operand fields (Tuition and Fees and Books) exactly as you want them. (Please see this guide.) However, you would have to delete the said fields and replace them and once that's done, all data which would have been submitted via the current fields will be deleted. So, please download all of the form's submissions to your computer before replacing the fields. Of course, you will need to edit the expression in the Total Expect(ed) Costs field to suit.

    And while we're on the subject of the total, there's still no way to have commas auto-inserted into that field's value, unless the aforementioned full source code and custom script workaround is used.

    Here's an abridged version of your jotform with the Masked Input widget.

    If you need further assistance with this, we'd be glad to provide it.

    Cheers

  • fhpw
    Replied on March 21, 2015 at 11:02 PM

    That looks great!  Thanks.  I will try it.  I have not taken the form live, so I have no problem making the change.  I am looking for consistency and the abridge version looks like it will work. I needed commas or the $ sign and decimals, but did not necessarily have to have both.

  • fhpw
    Replied on March 21, 2015 at 11:27 PM

    I applied the solution and it worked.  Thank you!

  • abajan Jotform Support
    Replied on March 22, 2015 at 6:23 AM

    You're quite welcome. If there's anything else with which you need assistance, please inform us.

    Cheers