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

help to modify Javascript

Participant ,
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

320

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

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;

Votes

Translate

Translate
Community Expert ,
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

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
Participant ,
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..

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