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

New to Acrobat Adobe, Need Assistance

New Here ,
Feb 28, 2020 Feb 28, 2020

Copy link to clipboard

Copied

I have been using Acrobat Adobe for a while now and have been able to do basic calculations. I have not worked with the "Custom calculation script" and was wondering if someone can help me with the calculation, if there is one.

 

I am wondering if there's a calculation for my statement below:

 

If "A" has a dollar amount and B is blank, answer is A;

If  both "A" and "B" have dollar amounts, fill answer with B.

 

Your help is greatly appreciated.

 

TOPICS
Acrobat SDK and JavaScript

Views

338

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

correct answers 1 Correct answer

Community Expert , Feb 29, 2020 Feb 29, 2020

If is best to write one of selection statements as mutually exclusive. 

 

 

var a = this.getField("A").value;
var b = this.getField("B").value;

if ((a != "") && (b !="")) event.value = b;
else if ( (a !="") && (b =="") ) event.value = a;
else event.value ="";

 

Votes

Translate

Translate
Community Expert ,
Feb 29, 2020 Feb 29, 2020

Copy link to clipboard

Copied

Assuming that you have three form fields named A, B, and Total, you can use a custom calculating script as shown   below for the Total field:

 

 

var a = this.getField("A").value;
var b = this.getField("B").value;

if (a && b !="") event.value = b;
if ( (a !="") && (b =="") ) event.value = a;

else event.value ="";

 

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 ,
Feb 29, 2020 Feb 29, 2020

Copy link to clipboard

Copied

If is best to write one of selection statements as mutually exclusive. 

 

 

var a = this.getField("A").value;
var b = this.getField("B").value;

if ((a != "") && (b !="")) event.value = b;
else if ( (a !="") && (b =="") ) event.value = a;
else event.value ="";

 

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
New Here ,
Mar 02, 2020 Mar 02, 2020

Copy link to clipboard

Copied

LATEST
thank you! it worked great.

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