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

Hide zero in field with an if/else formula

Explorer ,
Jan 15, 2016 Jan 15, 2016

Hi, I’m able to hide the zero in fields when fields have simple calculations, using as the last line:  if (sum !==0) {event.value = sum;} else {event.value = ""}

I have a field named LessRetainage with an if/else formula, and the formula works fine, but I’m not sure how to hide the zero, I’ve tried various versions and the zero still appears, any advice on the syntax of a line that would hide the zero would be appreciated.  Below is the formula:

var Contract = this.getField("TotalContractToDate");

var TCW = this.getField("TotalCompletedWorkStoredMaterials");

var Retainage = this.getField("LessRetainage");

if (TCW.value <=(.5 * Contract.value)) {Retainage.value = .05 * TCW.value} else {Retainage.value = .025 * Contract.value}

Thanks!

TOPICS
Acrobat SDK and JavaScript
468
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
LEGEND ,
Jan 15, 2016 Jan 15, 2016

The script you provided works with numeric values which do not have currency symbols or Percentage symbols. The latest versions of Acrobat seem to accept your script even if there are currency symbols present.

With older versions of Acrobat we used the AFNumber_Format function to modify the displayed result to include the currency symbol or not display it.

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 ,
Jan 15, 2016 Jan 15, 2016
LATEST

Ass this at the end of your code:

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

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