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

Adding Text Field Variables and printing it to another text field

Gb82790
Registered: Jun 18 2010
Posts: 2

I am trying to add five different text fields together without using the easy add so I can force a recalculate. I am having a problem adding the fields together and have it output the sum of the fields. Two of the five fields have if statements so that if another field on the form changes these fields will change and when these change the field that has the total should change but it doesn't. My way to fix this was to just write a simple sum script so I could force recalculate. The problem I am having is getting the sum to calculate correctly.
This is the code I have right now and it is giving me a NaN in the total field:
var a=this.getField("CON Base");
var b=this.getField("CON R");
var c=this.getField("CON E");
var d=this.getField("CON B");
var e=this.getField("CON P");
event.value = a.AsNumber+b.AsNumber+c.AsNumber+d.AsNumber+e.AsNumber;

Anyway you can help with writing a correct sum script or a better way to get the total field to readjust immediately after the if statement would change the CON R or CON B field.

This is what the field looks like:http://i175.photobucket.com/albums/w127/gb82790/script.png

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Just use the built-in method, but make sure the field calculation order is correct.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
What programing language are you using?

What errors are you getting on the Acrobat JavaScript debugging console?

You can not use field names with spaces in their name when using the simplified field notation method.

For this type of calculation I use a defined document level function, [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=25827]Adding text instead of numbers[/url].

Acrobat Forms use a variation of JavaScript and there is no 'AsNumber' property, but there is a "Number()" constrictor and a 'value' property.

George Kaiser