Custom Calculation Script in Adobe Acrobat Pro DC

New Here ,
Aug 16, 2017

Copy link to clipboard

Copied

I already have a custom calculation script setup but I wanted to fix it a bit.

var v1 = Number(this.getField("NMS").value); 

var v2 = Number(this.getField("CMS").value); 

var v3 = Number(this.getField("CMS").value); 

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

else event.value = (v1-v2)/v3;

The script is giving me what I want in percentage. But what if I enter $5,000 in field "CMS" but left a $0.00 or blank in the field "NMS" yes it will give me a -100% in percent box but that's not what I want. I want the percentage to stay as "0.00" because if I do it the other way around such as $5,000 in the field of "NMS" but left a a $0.00 or blank in the field I get a "0.00" in percentage box.

I need help from anyone.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

462

Likes

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

Custom Calculation Script in Adobe Acrobat Pro DC

New Here ,
Aug 16, 2017

Copy link to clipboard

Copied

I already have a custom calculation script setup but I wanted to fix it a bit.

var v1 = Number(this.getField("NMS").value); 

var v2 = Number(this.getField("CMS").value); 

var v3 = Number(this.getField("CMS").value); 

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

else event.value = (v1-v2)/v3;

The script is giving me what I want in percentage. But what if I enter $5,000 in field "CMS" but left a $0.00 or blank in the field "NMS" yes it will give me a -100% in percent box but that's not what I want. I want the percentage to stay as "0.00" because if I do it the other way around such as $5,000 in the field of "NMS" but left a a $0.00 or blank in the field I get a "0.00" in percentage box.

I need help from anyone.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

463

Likes

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
Aug 16, 2017 0

Have something to add?

Join the conversation