
1. Re: javascript only works for "easy" numbers (and multiplying error)
try67 Sep 1, 2011 7:22 AM (in response to valz617)Can you post the code you've used for these calculations?
Also, did you make sure that the field calculation order is correct?

2. Re: javascript only works for "easy" numbers (and multiplying error)
valz617 Sep 1, 2011 8:10 AM (in response to try67)Sure. The form looks like this: (Field Names are in quotes.)
1. Total Amount of Third Party Recovery "total third"
2. Accrued Compensation Lien "accrued" (I clicked in calculations and just clicked "value is the sum of the following: and then clicked the field
a. "indemnity benefits" names of a and b.)
b. "expenses of medical"
3. Expenses of Recovery "recovery expenses"
4. Balance of Recovery "balance" (Its supposed to be #1minus #2) I used this script:
this.getField("balance").value = thisgetField("totalthird").value  this.getField("accrued").value;
HiddenLockedField "percent" (The content is set to 100.)
5. Lien Expenses Reimbursement Rate "5" (#2 divided by #1 * 100) I used this script:
event.value = ""
var accrued = getField("accrued").value;
var totalthird = getField("totalthird").value;
var percent = getField("percent").value;
if(totalthird!null && total third!=0)
{event.value = accrued / totalthird * percent;}
6. Expenses Attributable to Lien "attribute" (Supposed to be #3 times #5.) I went to calculations, anc clicked on, "value is the product
of the following" and checked "recovery expenses" and "5".
7. Net Lien "netlien" (Supposed to be #2#6) I used this script:
this.getField("netlien").value = this.getField("accrued").value  this.getField("attribute").value;
8. Reimbursement Rate of Future Lia. "rate" (Supposed to be #3 divided by #1 * 100.) I used this script:
event.value = "";
var recoveryexpenses = getField("recoveryexpenses").value;
var totalthird = getField("totalthird").value;
var percent = getField("percent").value;
if (totalthird!=null && totalthird!=0)
{event.value = (recoveryexpenses / totalthird) * perent;}

3. Re: javascript only works for "easy" numbers (and multiplying error)
try67 Sep 1, 2011 8:13 AM (in response to valz617)In #5 there's an error in the code, in this expression:
totalthird!null
It should be:
totalthird != null
Are there any error messages in the JS console?

4. Re: javascript only works for "easy" numbers (and multiplying error)
valz617 Sep 1, 2011 8:16 AM (in response to try67)I know that the field order is right. The users are able to tab from 1 to 2
and just follow the nuber order, but I'm not sure about calculation order. How do you find/check that?
Also, here are the numbers that I used, and adobe gave me. (This is an incorrect one.)
1. 100,000
2. a.11,989.73
b. 39,905.06 2. 51,894.79
3. 41,229.45
4. 48,105.21
5. 51.89
6. 21,393.96
7. 30,500.83
8. 41.23

5. Re: javascript only works for "easy" numbers (and multiplying error)
try67 Sep 1, 2011 8:22 AM (in response to valz617)The tab order is not the same as the calculation order.
To check that go to Forms Edit mode and then go to Forms  Edit Fields  Set
Fields Calculation Order...

6. Re: javascript only works for "easy" numbers (and multiplying error)
valz617 Sep 1, 2011 8:22 AM (in response to try67)I hit control J and the javascript console appears, but no errors are shown.

7. Re: javascript only works for "easy" numbers (and multiplying error)
MediaSLML Sep 1, 2011 8:32 AM (in response to valz617)Im not sure what version of Acrobat your using but in 9 Pro
Goto 1. Forms
2. Edit fields
3. Set Field Calculation Order
I think that will be the source of your problem, I had a similar problem too.
(Gah, try67 you beat me to it while i was searching for the button!)

8. Re: javascript only works for "easy" numbers (and multiplying error)
try67 Sep 1, 2011 8:28 AM (in response to valz617)Check the field calculation order. I have a feeling it's that.

9. Re: javascript only works for "easy" numbers (and multiplying error)
valz617 Sep 1, 2011 8:42 AM (in response to try67)Thanks, I never knew there was something called a calculation order. I'm running a bunch of numbers through it nowjust to make sure.

10. Re: javascript only works for "easy" numbers (and multiplying error)
gkaiseril Sep 1, 2011 8:49 AM (in response to valz617)You should also be aware that the values used in calculations are the result of the calculation and not the rounded display value. This difference between the rounded displayed value and the unrounded calculation value can result in some significant differences if there are values from a division and then a multiplication. You may want to add some rounding of the intermediate results for your calculations.

11. Re: javascript only works for "easy" numbers (and multiplying error)
valz617 Sep 1, 2011 9:08 AM (in response to try67)I think you were right. I've tested a bunch of numbers now and it wll works out. (I've put the form in the regular users folder, so I'll get more feedback today or tomorrow.) But I can't thank you enough.

12. Re: javascript only works for "easy" numbers (and multiplying error)
valz617 Sep 1, 2011 9:10 AM (in response to gkaiseril)How do you do that? I've set the calculations to two decimal places, but that's about it.

13. Re: javascript only works for "easy" numbers (and multiplying error)
valz617 Sep 1, 2011 9:12 AM (in response to try67)Sorry, meant to post this up here. Thanks. I think you were right. I've tested it a bunch. I put it in the regular user folderso I'll get more feedback today or tomorrow, but hopefully this fixed it. I can't thank you enough. (Some of my coworkers were getting a little snippy about it.)

14. Re: javascript only works for "easy" numbers (and multiplying error)
gkaiseril Sep 1, 2011 11:01 AM (in response to valz617)You can use the 'util.printf()' method or write your own rounding routine using JavaScirpt's "Math.round()" method.
You posted the numbers you got from your script, but what were the values you were expecting or the values that were wrong?