Skip to main content
La-Marie
Known Participant
May 4, 2017
Question

JavaScript if var a is empty and var b is empty then make var c blank

  • May 4, 2017
  • 1 reply
  • 632 views

Need help with a javascript please.

I am using Adobe Acrobat Pro xi

Form has a Received, Paid and Balance column. All formatted to number. I have a script that calculates.

I am using the following Custom calculation script that works fine:

var a=this.getField("BRow1");

var b=this.getField("RRow2");

var c=this.getField("PRow2");

var d=this.getField("BRow2");

d.value=(a.value+b.value)-c.value;

I need an "if" statement. If var b (received) is empty and if var c (paid) is empty then var d (Balance) is blank.

Any help is greatly appreciated. Thank you.

This topic has been closed for replies.

1 reply

Joel Geraci
Community Expert
Community Expert
May 4, 2017

Is BRow2 showing "0" when the two fields are blank right now?

La-Marie
La-MarieAuthor
Known Participant
May 4, 2017

yes it is blank. When I add a number in the RRow1 (received1), I have BRow1 = the RRow1

Then the BRow1 shows up in BRow2

I hope that makes sense. Thank you.

La-Marie
La-MarieAuthor
Known Participant
May 4, 2017

I think I got it to work. Figures, first time I ask for help . . .

var a=this.getField("BRow1");

var b=this.getField("RRow2");

var c=this.getField("PRow2");

var d=this.getField("BRow2");

if ((b.value =="") && (c.value ==""))

{

  1. event.value = ""

}

else

{

  1. d.value=(a.value+b.value)-c.value;

}

Thank you so much for taking the time to reply.