Skip to main content
Participant
July 3, 2022
Question

JavaScript For calculation or any other formula

  • July 3, 2022
  • 1 reply
  • 2103 views

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. 

 

This topic has been closed for replies.

1 reply

ls_rbls
Community Expert
Community Expert
July 3, 2022

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.