Skip to main content
Participating Frequently
November 9, 2023
Question

Decimal places in "calculated" field

  • November 9, 2023
  • 1 reply
  • 1712 views

I searched through some other posts and can't figure out how to apply the answers to my situation.  

 

I have a detailed form.  Three of the fields towards the end of the form are:  Subtotal (which adds up 8 fields above); Plus5 (which calculates a 5% cushion on the Subtotal field); Total (which adds together Subtotal and Plus5.  

 

These calculations and formats (decimal places, etc.) are correct and I'm not having any trouble with those.

 

Then I have a Summary field which pulls in text and data from all the above fields that looks like this:

Conference Registration $ 500
Lodging $ 251.56 X 3 = $ 754.68

Out-of-State Total $ 1254.68
Plus 5% (In-State Only) $ 62.73400000000001
In-State Total $ 1317.414

 

This is a custom script that looks in part like this:

event.value = "Conference Registration  $ " + this.getField("ConfRegFee").value +

"\nLodging  $ " + this.getField("HotelCost").value + " X " + this.getField("HotelNights").value + " = $ " + this.getField("HotelTotal").value +

........ +
"\nOut-of-State Total $ " + this.getField("OOSTotal").value +
"\nPlus 5% (In-State Only) $ " + this.getField("Plus5").value + "\nIn-State Total $ " + this.getField("ISTotal").value

 

 

I have two questions.  

1) How do I get the Conference Registration line to show in the Summary with 2 decimal places?

2) How do I get the Plus 5% and the In-State Totals to round to 2 decimal places?

 

I'm thinking it has something to do with not formatting the fields as $, but as numbers with 2 decimals....  But, I can't seem to get that to work either..

 

Any assistance is appreciated!

Thanks,

Ruth

 

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
November 9, 2023

If you format the field as a number with two decimals also select currency sign and remove it from your script then.

If you wish to use script, you can use toFixed(2) to format value to two decimal places.

Participant
November 9, 2023

I'm sorry, but could you explain the currency change in more detail?

Nesa Nurani
Community Expert
Community Expert
November 9, 2023

When you format the field, you can also select currency: