4 Replies Latest reply on Dec 20, 2011 12:51 PM by gkaiseril

# multiply text boxes

Hello-

This is my first post; I need to do a simple calculation on a .pdf form -- multiply a quantity by a set number in another box, also is there a way to have the total at the bottom not calculate until a quantity is entered?

Example:

Quantity      Price

0                 \$11,500

0                 \$23,000

0                 \$975

etc

Total            \$0

then

Quantity      Price

1               \$11,500

0               \$23,000

0               \$975

etc

Total          \$11,500

• ###### 1. Re: multiply text boxes  Go to the Total's field's properties, Calculate tab, and enter something like this:

event.value = (Number(this.getField("Quantity1").value) * Number(this.getField("Price1").value)) + (Number(this.getField("Quantity2").value) * Number(this.getField("Price2").value)) +  (etc.)

Of course, you'll need to adjust the field names to match those in your file. The calculation will update each time you update the value of one of the fields (when you exit that field, not as you're typing it!).

• ###### 2. Re: multiply text boxes  In order to prevent the calculation of no quantities are entered, you'll have to test the values to see if any are not zero and proceed with the calculation in any are not. If all are zero, set event.value to 0.

• ###### 3. Re: multiply text boxes  There's no need to do that because Number("") returns 0.

• ###### 4. Re: multiply text boxes  For each row you can use the calculation option "Field is the product of fields:" to compute the row product.

For the total of the extended quantity x price you can use the "Field is the sum of fields".

Fore each calculated field you can use the following "Validation" script:

if(event.value == 0) event.value = "";

For the above to take effect you will either need to clear the form or perform a calculation.

You may also need to adjust the calculation order of the form fields.