Skip to main content
Known Participant
March 19, 2018
Answered

help to modify Javascript

  • March 19, 2018
  • 1 reply
  • 724 views

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;

This topic has been closed for replies.
Correct answer Thom Parker

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;

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
March 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 PDFScriptingUse the Acrobat JavaScript Reference early and often
omanbuxAuthor
Known Participant
March 19, 2018

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