These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Calculate two fields, hidden (blank) if one of the fields empty.

inta251
Registered: Nov 11 2010
Posts: 4

I have 3 fields
Field1 Field2 Field3
 
Field3 got custom calculation script:
 
var v1 = getField("Field1").value;
var v2 = getField("Field2").value;
event.value = v1 - v2;
event.target.hidden = (event.value <= 0);
 
When Field1 filled with number, Field3 got same number.
Need something to keep blank before Field2 filed with number.
 
Similar to Excel:
=IF(OR(Field1="",Field2=""),"",SUM(Field1-Field2))
 
Thanks in advance.
Igor.

My Product Information:
Acrobat Pro Extended 9.3.1, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Try this:

var v1 = getField("Field1").value;
var v2 = getField("Field2").value;
event.value = (v1 === "" || v2 === "") ? "" : v1 - v2;

inta251
Registered: Nov 11 2010
Posts: 4
Thanks George.
Script working perfect for me.
Thanks again!