JavaScript if var a is empty and var b is empty then make var c blank
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Is BRow2 showing "0" when the two fields are blank right now?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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 ==""))
{
- event.value = ""
}
else
{
- d.value=(a.value+b.value)-c.value;
}
Thank you so much for taking the time to reply.
Copy link to clipboard
Copied
Very nice. Half the time I figure out the answer just by trying to phrase the question in a way that others would understand.

