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

Calculation add & subtract script need looking at.

jenawyn
Registered: Apr 1 2011
Posts: 12
Answered

Hi..Anyone can help with this.
 
I want to do the following and have the result in a txt field.
 
I've tried this and does not work well...in simple calc
Text191+Text194+text197-Defin-Text209-Text212.
 
I have tried this in custom & it does not work correctly either.
 
event.value = this.getField("Text191").value + this.getField("Text194").value + this.getField("Text197").value - this.getField("Defin").value - this.getField("Text209").value - this.getField("Text212").value;
 
Can someone help please?
 
Cheers
Stephen
 

My Product Information:
Acrobat Pro 10.0.1, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Accepted Answer
Are you getting any errors in the JavaScript console?

You have capitalized 'Text197' differently in both statements.

Check to make sure all fields exist and are spelled and capitalized correctly.

George Kaiser

jenawyn
Registered: Apr 1 2011
Posts: 12
Hi George,

I actually just saw the text, Text boo boo and was reading about calculations when I found that the following adaption worked.

Info for anyone else trying this anyway.....

(Text191+Text194+Text197) - (Defin+Text209+Text212)

needed the brackets and a sort out of the calc to work without any weird stuff going on..
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
The parenthesis establish the order of the calculation. The default precedence is first multiplication and division then addition and subtraction.

George Kaiser