0
JavaScript For calculation or any other formula
Community Beginner
,
/t5/acrobat-discussions/javascript-for-calculation-or-any-other-formula/td-p/13047178
Jul 03, 2022
Jul 03, 2022
Copy link to clipboard
Copied
Hi
i need help i applied the formula in PDF Form for subtraction which is column3-column2+1 for calculation, now if some fields are left empty it shows in total column the value is 1, (if the column3 and column2 are left empty in total column4), help me. Also tell me if i can get my desired result of calculation with a single button, but same result as i asked.
TOPICS
How to
,
JavaScript
,
PDF forms
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
LATEST
/t5/acrobat-discussions/javascript-for-calculation-or-any-other-formula/m-p/13047349#M368951
Jul 03, 2022
Jul 03, 2022
Copy link to clipboard
Copied
This may be done in different ways.
But in my example below, I am executing the calculation from the total field "column4" as a custom calculation script instead of employing a button with an event action:
// declare your variables
var colum3 = this.getField("column3").value;
var column2 = this.getField("column2").value;
var total = (column3 - column2) + 1;
// establish a condition; if column3 or column2 have empty values column4 should remain empty
if (column3=="" || column2 ==""){
event.value ="";
// if the condition above is not met then execute calculation in target field column4
} else {
event.value = total;
}
See if the example above works for you.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

