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

Calculation for Greater than and lower than

REBECCACHUAH
Registered: Aug 26 2008
Posts: 3

Dear Anyone who may help me,

I'm a beginer user and i need HELP for the below for Acroform:

Say;

Field1 = 1
Field2 = 2
Field3 = (1-2)>0
= 0

Now, what i did was i go to
"custom calculation script"
"edit"

if(Field1-Field2)then
FieldC
elseif
FieldC>0then
0
endif

However, i can't get the answer. Please help me!

Thanks and good day

Becks

My Product Information:
Acrobat Pro 8.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The first thing you need to know is that the scripting language for Acrobat is JavaScript. You started off pretty good, but of course, in order to get this to work the language syntax has to be correct. You can find plenty of information about JavaScript on the internet. Or, the best thing to do is to purchase a JavaScript book, my favorite is the O'Reilly, "JavaScript, the Definitive Guide". The Acrobat JavaScript Reference and Guide can also be very helpful. You can download it from here:

http://www.adobe.com/devnet/acrobat/

And here's a link to an article on calculation scripts:
http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/form_calculations/

Next, the field values that will be used in the calculation have to be acquired and the result of the calculation has to be properly assigned to the field.
So, you're calculation script might look like this

var nFld1 = this.getField("Field1").value;var nFld2 = this.getField("Field2").value;var nFldC = this.getField("FieldC").value;  if( (nFld1 - nFld2) > 0){event.value = nFldC;}else if(nFldC > 0){event.value = 0;}

I don't know if this is exactly what you are trying to do, but the syntax is correct.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

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

REBECCACHUAH
Registered: Aug 26 2008
Posts: 3
Thomp,

I still can't get it right. My answer suppose to be "0" if the total is a negative.

Meanwhile, i'm trying to download the "Acrobat JavaScript Scripting
Reference". However, it came out "THERE WAS AN ERROR PROCESSING A PAGE. A FILE I/O ERROR HAS OCCURED".

I really need to solve this problem as soon. Any possiblity that your goodself can e-mail it to me?

:-)

Thanks & Good day.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You have not provided enough information about exactly what it is you need for the calculation. However, if you want a solution you'll need to do some reading to learn a bit about JavaScript and to find out about how calculations work in Acrobat. This isn't the sort of thing that happens quickly unless you already know what you are doing, or you hire a developer to do the work for you.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

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