3 Replies Latest reply on Feb 6, 2015 6:30 AM by helioc1227

# Help with hidden field formula

I have a table in Acrobat document:

Box 1 = User Inputed Data

Box 2 = User Inputed Data

Box 3 = User Inputed Data

Box 4 = (Box 1*Box2*Box3)

Box 5 = User Inputed Data

Box 6 = (Box 4 - Box 5)

The problem:

When this table opens up in the document all fields need to be blank for printing purposes.

However, all fields are fillable for someone to input data and then print off for convenvience.

What I need help on, is creating a script that allows Box 4 and Box 6 to remain blank but also perform thier function and show a set value of 0 if the function is validated as true.

Example:

Box 1 = 2

Box 2 = 2

Box 3 = 0

Box 4 = (Box 1*Box2*Box3) = 0

Box 5 = 0

Box 6 = (Box 4 - Box 5) = 0

Can anyone help me with this? Let me know if further explanation or screenshots are needed.

Thanks.

• ###### 1. Re: Help with hidden field formula

Are you saying that you only want to show a value of zero in the calculated fields if all of the input fields are not blank and the result of the calculation is zero? If so, a custom calculation script for the first one could be something like:

(function () {

// Get the field values as strings

var v1 = getField("Box 1").valueAsString;

var v2 = getField("Box 2").valueAsString;

var v3 = getField("Box 3").valueAsString;

if (v1 && v2 && v3) {

// Perform the calculation

event.value = v1 * v2 * v3;

} else {

event.value = "";

}

})();

The script for the other could be:

(function () {

// Get the field values as strings

var v1 = getField("Box 4").valueAsString;

var v2 = getField("Box 5").valueAsString;

if (v1 && v2) {

// Perform the calculation

event.value = +v1 - +v2;

} else {

event.value = "";

}

})();

• ###### 2. Re: Help with hidden field formula

That is exactly what I'm looking for. Thanks for the help!

• ###### 3. Re: Help with hidden field formula

One more question:

How could I also add to that script to say that if Box 1 = 0, then Box 6 automatically displays "0"?