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

Calculations in Forms

hctraining
Registered: Oct 5 2009
Posts: 4

I created an expense form in Acrobat 9. I have two fields with simple addition equations Total Employee Expenses and Less Amount of Advance.

What I want to do is create a statement that says:

"If the value in field Less Amount of Advance is greater than the value in field Total Employee Expense display the difference in a field called balance Due to the College, other wise leave blank". Then "If the value in field Less Amount of Advance is less than the value in field Total Employee Expense display the difference in a field called balance Due to the Traveler other wise leave blank.

Is this possible?

My Product Information:
Acrobat Pro 9.3.1, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi hctraining,

Sure this is possible. Read this article from the Learning Center here on writing conditional JavaScript statements-
http://www.acrobatusers.com/tutorials/conditional-execution

Hope this helps,

Dimitri
Windjack Solutions
www.pdfscripting.com
www.windjack.com
hctraining
Registered: Oct 5 2009
Posts: 4
Thank you Dimitri-

I've tried several different if statements to display only positive values in the field Balance Due and if the value is negative don't display.

If(value.Text108=positive, display) else (0)


Thoughts?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
You need to use the correct JavaScript syntax to access field objects, the values of the objects, the properties of the objects , and methods of objects.
// calculation  for field due employee // field namesvar sExpenses = "Total Expenses";var sAdvance = "Advance";var sDueSchool = "Due School"; // get field objectsvar oExpenses = this.getField(sExpenses); // total expensesvar oAdvance = this.getField(sAdvance); // total advancesvar oDueSchool = this.getField(sDueSchool); // due school // assume no monies owedevent.value = "";oDueSchool.value = ""; // compute balance due employeevar nBalDueEmployee = oExpenses.value - oAdvance.value; // if nBalDueEmployee > 0 monies owed to employeeif(nBalDueEmployee > 0)event.value = nBalDueEmployee; // if nBalDueEmployee < 0 employee owes schoolif(nBalDueEmployee < 0)oDueSchool.value = -1 * nBalDueEmployee;

You will have to change the strings for the field names to match your field names.

Comments start with the string "//".

George Kaiser

hctraining
Registered: Oct 5 2009
Posts: 4
Thank you so much for the java scripting. I have changed my field names to match those in the script however, not knowing anything about java script I am confused as to what field I am to insert the script. I tried creating a Trigger "On blur" and the action would be to run java script provided. However nothing happens. I originally entered the trigger on the Total expense field but that doesn't work do I need to add an additional field for the script to run and place in the correct field?