Skip to main content
RealEventDesigns
Participant
Feb 7, 2018 5:29 PM UTC
Question

Hide Acrobat Text Field Calculations if Value is Zero

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 is closed to new replies. Start a new post to keep the conversation going.

3 replies

Thom Parker
Community Expert
Community Expert
Feb 7, 2018 7:29 PM UTC

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.

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
RealEventDesigns
Participant
Feb 7, 2018 7:28 PM UTC

Yes that works!

Thank You!!

Translate
try67
Community Expert
Community Expert
Feb 7, 2018 5:55 PM UTC

Use this code instead:

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

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

Translate