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

Calculations

krickett47
Registered: Feb 4 2010
Posts: 18

How do I write a calculation in the properties of a field. I want to divide field 231 (that is the name of the field) by 100.

Thanks!

My Product Information:
Acrobat Standard 9.0, Windows
Appligentdocume...
Registered: Oct 10 2008
Posts: 26
Go to the Calculations tab of the field properties.

Here you can enter a custom calculation using javascript.

If I'm correct in understanding that you want field "231" to display the entered value divided by 100, enter the following into the custom calculation:

event.value = event.value / 100 ;

If you wanted to display the result of the calculation in another field enter the following in field "231":

this.getField("PLACE_FIELDNAME_HERE").value = event.value / 100 ;



Appligent Document Solutions
www.appligent.com

Appligent Document Solutions
http://www.appligent.com

krickett47
Registered: Feb 4 2010
Posts: 18
Still not working.
This is the code I used. this.getField("FillText230").value = event.value / 100;
The figure in FillText230 is 40.
I get nothing in 231.
Appligentdocume...
Registered: Oct 10 2008
Posts: 26
Can you please tell me what field you placed the script into?

And where are you entering the value that needs to be divided by 100?

If you want to enter the value in 231 and have the result in FillText230, you need to place the line of code you have in the Custom Calculation of fields 231. The value you enter into 231 will not change. That value, divided by 100 should appear in field FillText230.

Appligent Document Solutions
http://www.appligent.com

mingdichen
Registered: Jan 7 2010
Posts: 29
Can you try this:

In the Field231 Calculation Event:

this.rawValue=FillText230.rawValue/100;


It should take the FillText230 vaule and divide by 100;

But, first you need to make sure that field231, and FillText230 are numeric fields or decimal fields.

Maybe, your problem is field231 is set as Text field??
try67
Expert
Registered: Oct 30 2008
Posts: 2398
mingdichen, that code is for LiveCycle forms and will not work with Acrobat forms.

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

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You need to use the supplied code with a modification:
this.getField("PLACE_FIELDNAME_HERE").value = event.value / 100 ;
You need to replace 'PLACE_FIELDNAME_HERE' with the field name of the field you want the result to be placed in. Be sure to keep the double quote marks, as these are used to indicate the text string for the field name.

George Kaiser

EvelynT
Registered: Feb 11 2010
Posts: 4
I am trying to do a custom calculation and this is what I have typed in:

var a = this.getField("Total Funding RequestedRow1").value;
var b = this.getField("Number of Clients to be ServedRow1").value;
var c = this.getField("Unit of Service to be ProvidedRow1").value;
Cost per Client per Unit of ServiceRow1.value = a/(b*c)

I am trying to divide variable a by the result of (variable b times variable c) and have that result in it's own column. I am not getting an error, but its not doing any calculation.
Can someone help me please?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Is this Acrobat or LiveCycle? Where is this script placed?
If Acrobat, you should place it in the custom calc of the last field and change the last line to:
event.value = a/(b*c)

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

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
EvelynT wrote:
I am trying to do a custom calculation and this is what I have typed in:var a = this.getField("Total Funding RequestedRow1").value;
var b = this.getField("Number of Clients to be ServedRow1").value;
var c = this.getField("Unit of Service to be ProvidedRow1").value;
Cost per Client per Unit of ServiceRow1.value = a/(b*c)

I am trying to divide variable a by the result of (variable b times variable c) and have that result in it's own column. I am not getting an error, but its not doing any calculation.
Can someone help me please?
If this custom JavaScript calculation is for the "Cost per Client per Unit of ServiceRow1", you should be using the 'event' object and the 'value' property.

I have a message about a missing semicolon because you appear to be accessing a field name but not using the field object for that field.

What would happen if you divide (b X c) is zero/

var a = this.getField("Total Funding RequestedRow1").value;var b = this.getField("Number of Clients to be ServedRow1").value;var c = this.getField("Unit of Service to be ProvidedRow1").value;// compute the valueevent.value = '';if( (b * c) != 0) {// perform only is b * c is not zeroevent.value = a / (b * c)}

George Kaiser

krickett47
Registered: Feb 4 2010
Posts: 18
This information was so helpful! Thank you!