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

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

Community Beginner ,
May 04, 2017 May 04, 2017

Need help with a javascript please.

Balance adobe pic.png

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.

TOPICS
Acrobat SDK and JavaScript
574
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
Community Expert ,
May 04, 2017 May 04, 2017

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

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
Community Beginner ,
May 04, 2017 May 04, 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.

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
Community Beginner ,
May 04, 2017 May 04, 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.

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
Community Expert ,
May 04, 2017 May 04, 2017
LATEST

Very nice. Half the time I figure out the answer just by trying to phrase the question in a way that others would understand.

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