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

Trying to multiply two fields on a purchase req and have zeros be blank

New Here ,
Feb 09, 2017 Feb 09, 2017

I am new to Javascript programming in adobe.  I have a purchase req that needs to multiply the qty and the unit cost to get an extended cost.  I know I can do this in a simple calculation, but I also want fields that are zero to return blank.  the code I have so far is:

event.value=(this.getField("QtyRow1").value * this.getfield("UnitCostRow1").value);

If(event.value==0) event.value = "";

neither stablemen is working.  The first does not seem to calculate and the second give me the missing; before statement 2 error...any help you can give would be great.

TOPICS
Acrobat SDK and JavaScript , Windows
553
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 , Feb 10, 2017 Feb 10, 2017

event.value=(this.getField("QtyRow1").value * this.getField("UnitCostRow1").value);

If(event.value==0) {event.value = "";}

Translate
Community Expert ,
Feb 09, 2017 Feb 09, 2017

You'll want to actually leave the calculated value as zero. You can set how "0" displays in a custom format script like the following.

if (event.value == 0) {

    event.value = "";

}

So leave your calculation (the first line, where it is. Move the second line to the Custom Format Script in the other tab.

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 ,
Feb 10, 2017 Feb 10, 2017

There's an error in your code. Did you check the JS Console?

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 ,
Feb 10, 2017 Feb 10, 2017

event.value=(this.getField("QtyRow1").value * this.getField("UnitCostRow1").value);

If(event.value==0) {event.value = "";}


Acrobate du PDF, InDesigner et Photoshopographe
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
New Here ,
Feb 10, 2017 Feb 10, 2017
LATEST

Thanks...this seemed to solve it!  Appreciate your help.

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