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

Text Field Properties How to write an IF formula

Explorer ,
Aug 24, 2023 Aug 24, 2023

Hello,

 

I would like to know if it is possible use Calculate to add text fields but leave them blank if they are not used.  For example:

 

Using, say, an expenses form ... The first receipt total box will have data entered, then the running total.  If the second and third etc. are not used then they should remain blank and not calculate anything.  I have attached a picture, I hope what I'm saying makes sense.

 

I appreciate your time and help with this.

 

TOPICS
How to , JavaScript , PDF , PDF forms
648
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
Explorer ,
Aug 24, 2023 Aug 24, 2023
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 ,
Aug 24, 2023 Aug 24, 2023

So you only want Total_2 to show a value if Total is not empty?

If so, you can do it using this code as the Calculation script of Total_2:

 

var total = this.getField("Total").valueAsString;

if (total=="") event.value = "";

else event.value = Number(total) + Number(this.getField("Amount 2").valueAsString);

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 ,
Aug 25, 2023 Aug 25, 2023
LATEST

Read these two articles:

https://www.pdfscripting.com/public/How-to-write-an-If-statement.cfm

https://www.pdfscripting.com/public/How-to-Write-a-Basic-PDF-Calculation-Script.cfm

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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