Skip to main content
RealEventDesigns
Participant
February 7, 2018
Question

Hide Acrobat Text Field Calculations if Value is Zero

  • February 7, 2018
  • 3 replies
  • 315 views

Hello,

I am creating an invoice form where I've put in the calcuations to generate an amount for the "Amount" field. However, it's showing 0.00 where the "Amount" field is zero. How do I make it that it shows nothing when it's zero. I tried using the following script in the Custom Calculation Script under the calculation tab.

Amount2.value = this.getfield("Qty2").value * this.getfield("UP2").value;

if (Amount2.value == 0) Amount2.value = "";

When inputting this, the field just becomes blank.

Can anyone help meÉ

This topic has been closed for replies.

3 replies

Thom Parker
Community Expert
Community Expert
February 7, 2018

Setting the output to an empty string only works if a real number value is not needed by another calculation or as an export value. If either of these is the case, then I'd suggest using a format script to blank the field. Format scripts only affect the display of a field and don't change the real value.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
RealEventDesigns
Participant
February 7, 2018

Yes that works!

Thank You!!

try67
Community Expert
Community Expert
February 7, 2018

Use this code instead:

var amount = Number(this.getField("Qty2").value) * Number(this.getField("UP2").value);

event.value = (amount==0) ? "" : amount;