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

Calculations in text boxes.

rnj3
Registered: Nov 30 2007
Posts: 2

The following is being used in a form:
 
I am adding together numbers from a series of text boxes to show a result in a final text box. At times I need to takes one of the text boxes out of the series of text boxes that I am adding. Can I do this either by setting up a check box or clicking a button. How do I do this?

My Product Information:
Acrobat Pro 8.0999999999999996447286321199499070644378662109375, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are a couple of ways to take a field out of a calculation. You check box suggestion would work fine. Use a script that looks something like this:
(I haven't included real field code since you didn't specify whether this was for AcroForms or XFA Forms.

var sum = 0;
if(..Check One is on..)
sum += (..Text One Value..);
if(..Check two is on..)
sum += (..Text two Value..);
if(..Check three is on..)
sum += (..Text three Value..);

You could also check for empty field entries. This is a common method, i.e. don't include anything that isn't filled in. The code is similar to the example above except that the field value is tested for a non-numeric value. Use the "NaN()" function.

For example

if( !NaN(.. Field value..))
sum += (..Field value ..);

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script