• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Require javascript formula to determine percentage in Acrobat DC Pro form

Explorer ,
Dec 20, 2019 Dec 20, 2019

Copy link to clipboard

Copied

I have a form that requires percentage to be calculated using values input by person filling form.

Text4.0 is no. of attendees

Text4.1 is no. of Employees

Text 4.2 is the percentage calculation

TOPICS
Acrobat SDK and JavaScript

Views

484

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 20, 2019 Dec 20, 2019

Copy link to clipboard

Copied

For the case of the number of employees being non-zero, I would divide the number of attendees by the number of employees. I would set the field format to the percentage display format and specify the number of decimal places to display. Acrobat JavaScript considers division by zero to result in Not a Number or NaN. One can only use the Custom JavaScript calculation method.

 

// get computational  values;

var nAttendees = this.getField("Text4.0").value;
var nEmployees = this.getField("Text4.1").value;

event.value = 0;

// clear result field;

if(nEmployees != 0){

// compute if divisor not zero;
event.value = nAttendees / nEmployees
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 20, 2019 Dec 20, 2019

Copy link to clipboard

Copied

That works great! Thanks for the information. 

 

This may be ao ongoing requirement for my business. Do you have a suggestion as to how I can either

a) learn how to do this

b) contract someone to do this. 

 

Thanks again!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2019 Dec 20, 2019

Copy link to clipboard

Copied

LATEST

Here is a site all about Acrobat Scripting (there's plenty of free material to look over):

https://www.pdfscripting.com/public/main.cfm

 

For contract work, contact me:

http://www.windjack.com/

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines