6 Replies Latest reply on Jan 20, 2015 5:22 AM by richdjr

Need help with percentages in acrobat x pro

Hi all,

I'm really new to creating fillable forms. I'm revising a document for work and I need to calculate a percentage for earnings. For instance:

If an employee was making 88,0000 and their salary was increased to 98,000 I need the percentage to reflect an increase of 11.36%

Everything I've tried thus far doesn't give me the correct answer I'm looking for. HELP!!

• 1. Re: Need help with percentages in acrobat x pro

What did you try?

This is basically a simple division of the difference of the (New Salary - Old Salary) / old Salary and the result formatted as a Percentage.

• 2. Re: Need help with percentages in acrobat x pro

The closest I came was:

// Custom calculation script

(function () {

// Get the field values, as strings

var s1 = getField("Charged").valueAsString;

var s2 = getField("Reduction").valueAsString;

// Perform the calculation if both fields are not blank

// and Charged is not zero

if (s1 && s2 && +s1 !==  0) {

event.value = 100 * (+s1 - +s2) / +s1;

} else {

event.value = "";

}

})();

which I got from another thread. It works, but the result tends to have a - before the number. Also when I use the formatting in acrobat and select percentage the decimal placement gets confusing. I'm creating this form for a bunch of morons in my HR department so extraneous numbers makes them confused. I need the most simplified result possible.

• 3. Re: Need help with percentages in acrobat x pro

I would have used:

// Get the field values, as strings

var s1 = this.getField("Charged").value; // original salary;

var s2 = this.getField("Reduction").value; // new salary;

// Perform the calculation if both fields are not blank

// and Charged is not zero

if (s1 !=  0) {

event.value = (Number(s2) - Number(s1))  /  Number(s1);

AFPercent_Format(2,0);

} else {

event.value = "";

AFNumber_Keystroke(2, 0, 0, 0, "", false);

}

The field's format is set to None because the script will set the format as needed.

• 4. Re: Need help with percentages in acrobat x pro

This is the result. I need 15.29%

• 5. Re: Need help with percentages in acrobat x pro

I cannot see the exact form field names and scripts used in you form from an image.

Works for me.

There must be something else I cannot see.

• 6. Re: Need help with percentages in acrobat x pro

So sorry! I had a 3 day weekend! I closed out of the program, re-entered the script and it works perfectly! Thank you so much!