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

Percentages help?

ark_1717
Registered: Apr 22 2008
Posts: 14

I have a form where I need to add the dollar amounts for projected small business spend and large business spend. (which is entered by the user) Then, actual cumulative smal and large spend is also entered by the user.

I need to know how to write the script for calculating the percentage of cumulative spend in relation to projected spend.

cumulative spend = % of projected spend
Projected spend = 200.00
50.00 is what % of 200.00

Any help is appreciated.

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Have you looked at the 'Scripting Reference' in LiveCycle Designer? You need to understand that there are 2 scripting languages used in LiveCycle Designer and their syntax is different.

The '/' is used for division and the '*' is used for multiplication.

A FormCalc calculation script for the 'cumulative spend' field is:

if(ProjectedSpend ne 0) then
(ActualSpend / ProjectedSpend) * 100
else
null
endif

George Kaiser

ark_1717
Registered: Apr 22 2008
Posts: 14
Here is the code I tried:

if(TotalCurrent ne 0) then
(SmallActual / TotalCurrent) * 100
else
null
endif

Here is the error:

Script failed (language is formcalc; context is
xfa[0].form[0].topmostSubform[0].Page1[0].SmallActual[0])
script=endif
Error: syntax error near token 'endif' on line1, column 5.

Any help is appreciated. I am new to this program.
KathrynGZ
Registered: Apr 15 2008
Posts: 35
I copied this formula into a form of mine and changed the field names (since I don't have those fields)--and it worked perfectly.

Is this the only code on this field event, or is there more code above? It is odd that the error message indicates an error on line *1* near endif. What's on line 1?

Which event did you put the code on?

Finally, if this is the only code on the event, since it's short you may try deleting it and retyping it. I've had that work in the past--I can only assume there was some error I didn't see and typing it fixed the error :)

Kathryn