How do I round up a number to the nearest 100 when a user enters in a value in a form field.

I am trying to get a field to round up to the nearest hundred dollar amount with no cents behind the amount. I think that I need to enter in some java cost but not sure if the code that I am using is correct. I am not getting any errors when I enter it in but it is doing nothing when I enter in a value in the field.


Math.round(someNumber/100)*100


David Malloy


4 Answers

Voted Best Answer

If you always want to round up, you would use Math.ceil() instead of Math.round(); all the rest would be the same.

Hope this can help.

Max Wyss.


By Max Wyss   

The basic code is correct, but it has to be connected to the field.

The easiest way would be to use the Calculate event, where you would enter this:

event.value = Math.round((event.value*100)/100) ;

And that should do it. However, be careful that the calculation order is correct if you have several fields using calculations.

Hope this can help.

Max Wyss.


Max Wyss   

Max is correct for an AcroForm. Did you create this form in Acrobat or in LiveCycle Designer.


Thom Parker   

Okay. It works but I think I explained what I was trying to do incorrectly.

Here is a example of what I need the field to do.
If I enter in $ 64.53
I need it to show $ 100.00

or

If I enter in $ 7.53
I need it to show $ 100.00

Basically I need it to go to the Highest 100 dollars. Is that possible to do with the built in functions?


David Malloy   


Please specify a reason: