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

Hiding sum of calculation, dependent on 3 fields being empty

407chelsie
Registered: Dec 8 2008
Posts: 68
Answered

I have a very complicated calculation that works beautifully, but I need the result to be hidden unless one of three fields has a number in it. In other words, if field A and field B and field C are all empty, the total field would also be empty, but once a number is entered in A, B or C, the total field would then run the calculation and show the result. Can anyone help me?

My Product Information:
Acrobat Pro 8.1.2, Macintosh
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You can use the if then else statement:

// get the input values as numbers
var A = Number(this.getField("Text2.0").value);
var B = Number(this.getField("Text2.1").value);
var C = Number(this.getField("Text2.2").value);
// sum the values
event.value = A + B + C;
// if all input fields are zero hide dispaly else display result
if((A == 0) & (B == 0) & (C == 0)) {
this.getField(event.target.name).display = display.hidden;
} else {
this.getField(event.target.name).display = display.visible;
}

George Kaiser

407chelsie
Registered: Dec 8 2008
Posts: 68
Wow, that's awesome. Thanks for teaching me so much!