Text Field Properties How to write an IF formula
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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
Use the Acrobat JavaScript Reference early and often

