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

Do calculation and don't show if zero

Community Beginner ,
Sep 03, 2025 Sep 03, 2025

I have a text field, called T1, with a formula in the Simplified field notation box.  The formula is to take a number entered in another text field, T2, and multiply it by 5.  The formula is T2*5.  If there is no number entered in T2, I would like to hide the zero in T1.  Normally, I would enter the following as a Custom calculation script in T1:  if(event.value == 0) event.value = "";

But, I can't use both a Simplified field notation and a Custom calculation script in T1.  Any ideas?  Thanks.

TOPICS
JavaScript , PDF , PDF forms
110
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
1 ACCEPTED SOLUTION
Community Expert ,
Sep 03, 2025 Sep 03, 2025

Or simply use a custom calculation script:

 

var t2 = Number(this.getField("T2").valueAsString);
if (t2==0) event.value = "";
else event.value = t2*5;

View solution in original post

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 ,
Sep 03, 2025 Sep 03, 2025

Leave your simplified field notation, and enter your script as a custom format script.

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 ,
Sep 03, 2025 Sep 03, 2025

Or simply use a custom calculation script:

 

var t2 = Number(this.getField("T2").valueAsString);
if (t2==0) event.value = "";
else event.value = t2*5;
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 ,
Sep 03, 2025 Sep 03, 2025
LATEST

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