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

help to modify Javascript

Participant ,
Mar 19, 2018 Mar 19, 2018

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
617
Translate
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;

Translate
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;

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

Translate
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
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..

Translate
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