help to modify Javascript

Explorer ,
Mar 19, 2018 Mar 19, 2018

Copy link to clipboard

Copied

hi, i'm using bellow calculating script & it's working. what i want to do is, if any of field is empty, calculation result field should be empty. pls help me. thanks in advance. thanks..

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

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

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

else event.value = v1/v2;

TOPICS
Acrobat SDK and JavaScript, Windows

Views

49

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Mar 19, 2018 Mar 19, 2018
Just add all fields to the existing "if" statementLike this:var v1 = Number(this.getField("amt11").value); var v2 = Number(this.getField("EX").value);if ((v1==0)  || (v2==0)) event.value = ""; else event.value = v1/v2;

Likes

Translate

Translate
Adobe Community Professional ,
Mar 19, 2018 Mar 19, 2018

Copy link to clipboard

Copied

Just add all fields to the existing "if" statement

Like this:

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

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

if ((v1==0)  || (v2==0)) event.value = "";

else event.value = v1/v2;

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

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
community guidelines
Explorer ,
Mar 19, 2018 Mar 19, 2018

Copy link to clipboard

Copied

LATEST

https://forums.adobe.com/people/Thom+Parker  wrote

Just add all fields to the existing "if" statement

Like this:

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

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

if ((v1==0)  || (v2==0)) event.value = "";

else event.value = v1/v2;

thanks a lot & it's work. thanks..

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
community guidelines