Expand my Community achievements bar.

SOLVED

How do I round up a total to the nearest dollar?

Avatar

Level 4

I have a form that multiplies the number of items by $6.07 but I need the total to round up to the nearest dollar. I have formatted the total field to be integer and selected integer in the binding tab, which works to drop the cents out of the total but that doesn't help it round up. I suspect a script is needed to accomplish this. How do I write this script?

Thanks for your help.

1 Accepted Solution

Avatar

Correct answer by
Level 10

You will want to use the Ceil function instead, which returns the next whole number greater than the expression, so;

Ceil(Table2.Row8.Eight * 6.07)

Just note that this will only for positive numbers, if you have to deal with negative numbers (maybe a refund) then you will need to use the Floor function.

Regards

Bruce

View solution in original post

7 Replies

Avatar

Level 10

Hi,

In JavaScript you can use the toFixed method of the number object to round to an whole number. So if variable total had a value of 10.5 then total.toFixed() would give you 11.

One catch is that toFixed() returns a string value so it might not format exactly how you expect, so

parseInt(total.toFixed())

Will return a number value.

Regards

Bruce

Avatar

Level 4

I already have a FormCalc script in that field. Here is what I have:

Table2.Row8.Eight * 6.07

And this parseInt line is Javacript.

So how would I write the whole script?

Avatar

Level 10

Hi,

The FormCalc equivilant is the Round function, so;

Round(Table2.Row8.Eight * 6.07, 0)

With the second parameter to Round being the number of decimal places, which defaults to zero so in this case you could just write;

Round(Table2.Row8.Eight * 6.07)

Regards

Bruce

Avatar

Level 4

Thank you!!!!!

Date: Mon, 11 Jun 2012 16:14:20 -0600

From: forums@adobe.com

To: jeanetteeichhorn@hotmail.com

Subject: How do I round up a total to the nearest dollar?

Re: How do I round up a total to the nearest dollar?

created by BR001 in LiveCycle Designer - View the full discussion

Hi, The FormCalc equivilant is the Round function, so; Round(Table2.Row8.Eight * 6.07, 0) With the second parameter to Round being the number of decimal places, which defaults to zero so in this case you could just write; Round(Table2.Row8.Eight * 6.07) Regards Bruce

Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:

To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.

Start a new discussion in LiveCycle Designer by email or at Adobe Forums

For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

Avatar

Level 4

I'm sorry to be such a dunce, but it's still rounding down and not up. If I put a quantity of one in the table and it multiplies by 6.07 the total shows as $6.00.

Avatar

Correct answer by
Level 10

You will want to use the Ceil function instead, which returns the next whole number greater than the expression, so;

Ceil(Table2.Row8.Eight * 6.07)

Just note that this will only for positive numbers, if you have to deal with negative numbers (maybe a refund) then you will need to use the Floor function.

Regards

Bruce

Avatar

Level 4

Ok, I will try this on my form and let you know how it went. Thanks so much for your continued support.

Date: Tue, 12 Jun 2012 16:12:57 -0600

From: forums@adobe.com

To: jeanetteeichhorn@hotmail.com

Subject: How do I round up a total to the nearest dollar?

Re: How do I round up a total to the nearest dollar?

created by BR001 in LiveCycle Designer - View the full discussion

You will want to use the Ceil function instead, which returns the next whole number greater than the expression, so; Ceil(Table2.Row8.Eight * 6.07) Just note that this will only for positive numbers, if you have to deal with negative numbers (maybe a refund) then you will need to use the Floor function. Regards Bruce

Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:

To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.

Start a new discussion in LiveCycle Designer by email or at Adobe Forums

For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.