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

Can you help me to insert a JAVA script into an Adobe PDF form I have created.

Community Beginner ,
Jul 22, 2016 Jul 22, 2016

I have never programmed in Java and need a Java script to insert into a calculation field in an Adobe PDF form I am creating using Adobe Acrobat Pro DC.  This form will be one that can be filled out on the PC or printed out and filled in manually.  The calculated field will display an unwanted zero when printed out and I want it to be blank.  Another field will be a calculated percent and displays an error when there is no divisor; similar problem, I want it to be blank and have the person filing out the form manually to calculate the field and write it in.  I don't have time to learn

The Excel formula would be:  If(Cell_1A="","",Cell_1A+Cell_1B)

What would the JAVA script be in a "Simplified Field Notation" or "Custom Calculation Script" dialog box?

TOPICS
Acrobat SDK and JavaScript , Windows
1.4K
Translate
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

correct answers 1 Correct answer

Community Expert , Jul 23, 2016 Jul 23, 2016

Both of these things require a custom calculation. For the division script you can use something like this:

var a = Number(this.getField("Field A").value);

var b = Number(this.getField("Field B").value);

if (b==0) event.value = "";

else event.value = a/b;

For the conditional script you can use this:

var a = this.getField("Cell_1A").valueAsString;

var b = this.getField("Cell_1B").valueAsString;

if (a=="") event.value = "";

else event.value = Number(a)+Number(b);

Translate
Community Expert ,
Jul 23, 2016 Jul 23, 2016

Both of these things require a custom calculation. For the division script you can use something like this:

var a = Number(this.getField("Field A").value);

var b = Number(this.getField("Field B").value);

if (b==0) event.value = "";

else event.value = a/b;

For the conditional script you can use this:

var a = this.getField("Cell_1A").valueAsString;

var b = this.getField("Cell_1B").valueAsString;

if (a=="") event.value = "";

else event.value = Number(a)+Number(b);

Translate
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 Beginner ,
Jul 26, 2016 Jul 26, 2016

Thank you for the solution.  It solved my problem.

Translate
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 ,
Jul 23, 2016 Jul 23, 2016

You should note that this is JavaScript (one word, no space, capital S). It is not Java or Java Script. These would be different things. This may not seem important, but if you are searching the web for advice it's very important not to get the wrong stuff, which will be similar enough to trick you, but won't work.

Translate
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 Beginner ,
Jul 26, 2016 Jul 26, 2016
LATEST

I do appreciate the people who correct my misstatements.  In the future I'll use JavaScript correctly.  Thank you.

Translate
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