Skip to main content
Participant
February 13, 2017
Answered

How do I round up/down calculated fields in Acrobat Pro DC?

  • February 13, 2017
  • 1 reply
  • 5587 views

I need Javascript for rounding solutions in two calculated fields in an Acrobat Pro DC form (I am almost totally unsavvy about Javascript, well, actually, totally.):

I need to round UP to the next whole number the results in one calculated field whose basic calculation is this:

(*THIS CALCS HOW MANY DAYS A JOB WILL TAKE)

// Get first field value, as a number

var v1 = +getField("qty").value;

// Get second field value, as a number

var v2 = +getField("wordsperday").value;

// Calculate and set this field's value to the result

event.value = v1 * v2;

--------------------------------

I need to round DOWN to the next whole number the results in one calculated field whose basic calculation is this:

(THIS CALCS HOW MUCH A JOB WILL COST)

// Get first field value, as a number

var v3 = +getField("qty").value;

// Get second field value, as a number

var v4 = +getField("rate").value;

// Calculate and set this field's value to the result

event.value = v4 * v3;

I have tried a few copy-and-paste scripts from the web; they did not work, and my efforts to tweak them into working also failed.

I will be eternally grateful for any help I receive.

Thanks,

Paul

.

This topic has been closed for replies.
Correct answer try67

Round up:

event.value = Math.ceil(v1 * v2);

Round down:

event.value = Math.floor(v4 * v3);

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 13, 2017

Round up:

event.value = Math.ceil(v1 * v2);

Round down:

event.value = Math.floor(v4 * v3);

Participant
February 13, 2017

Thanks! It worked perfectly and was much simpler than copy-and-paste scripts I found that did not work.

PH