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

JavaScript For calculation or any other formula

Community Beginner ,
Jul 03, 2022 Jul 03, 2022

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
1.7K
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 ,
Jul 03, 2022 Jul 03, 2022
LATEST

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.

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