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

How to create a custom script that will output a calculation but display 0 if the sum is a negative number Please Help!

New Here ,
Jul 07, 2017 Jul 07, 2017

Copy link to clipboard

Copied

I am trying to create a custom javascript calculation that will do the following:

Caculate: Subtract AGI_Total - (Deductions +Exemptions) and the result would go into the Taxable_Income field

I can do this in the Simplified Field notation of the Taxable_Income field on the PDF form I am working on but what I am having trouble doing is if the sum equals a negative number, I want the Taxable_Income field to display 0. Unfortunately, I am very new at Javascript and I don't know how exactly to do this. I am using Adobe Acrobat Pro.

Can someone help please?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

408

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 , Jul 07, 2017 Jul 07, 2017

Use this code as the field's custom calculation script:

var result = Number(this.getField("AGI_Total").value) - (Number(this.getField("Deductions").value) + Number(this.getField("Exemptions").value));

if (result<0) result = 0;

event.value = result;

Votes

Translate

Translate
Community Expert ,
Jul 07, 2017 Jul 07, 2017

Copy link to clipboard

Copied

Use this code as the field's custom calculation script:

var result = Number(this.getField("AGI_Total").value) - (Number(this.getField("Deductions").value) + Number(this.getField("Exemptions").value));

if (result<0) result = 0;

event.value = result;

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 ,
Jul 07, 2017 Jul 07, 2017

Copy link to clipboard

Copied

LATEST

It works! Thank you! and thank you for the speedy response!

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