Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Calculation Mystery
  FAQ FAQ  Forum Search   Register Register  Login Login

Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Calculation Mystery

 Post Reply Post Reply
Author
lolly View Drop Down
New Member
New Member


Joined: 15 Jul 2011
Location: US
Points: 5
Post Options Post Options   Quote lolly Quote  Post ReplyReply Direct Link To This Post Topic: Calculation Mystery
    Posted: 12 Oct 2011 at 6:13pm

I have several users in an international office who get different results with a JavaScript calculation in a form.  I have checked their preferences in Reader 7.0 and they are the same as the users who get the correct result. 

Here's my script:
 
var f = this.getField("excRate");
var g = this.getField ("Check_Amount");
if (f.value != "");
event.value = (g.value / f.value);
 
Using the following -- Amount: 190,437.50 and Rate: 32.1100, the users with the issue get 5,951.16 and the other users get the correct result of 5,951.78.
 
Any idea what could be causing this?
Back to Top
aandi View Drop Down
Senior Member
Senior Member


Joined: 07 Jul 2011
Points: 18358
Post Options Post Options   Quote aandi Quote  Post ReplyReply Direct Link To This Post Posted: 12 Oct 2011 at 6:27pm
Isn't the right answer 5,930.7848 ?
Back to Top
lolly View Drop Down
New Member
New Member


Joined: 15 Jul 2011
Location: US
Points: 5
Post Options Post Options   Quote lolly Quote  Post ReplyReply Direct Link To This Post Posted: 12 Oct 2011 at 6:38pm
Yes, sorry -- cut and paste error on my part.  The correct amount is 5,930.78 (rounded).
Back to Top
aandi View Drop Down
Senior Member
Senior Member


Joined: 07 Jul 2011
Points: 18358
Post Options Post Options   Quote aandi Quote  Post ReplyReply Direct Link To This Post Posted: 12 Oct 2011 at 7:35pm
I don't have a solution but I observe that
190,437 / 32.1100 = 5,951.16 (rounded to two places).
 
Perhaps there is a clue here.
 
Are the users accessing the same file e.g. from an intranet site, or do they each have a copy which should be identical?
Back to Top
lolly View Drop Down
New Member
New Member


Joined: 15 Jul 2011
Location: US
Points: 5
Post Options Post Options   Quote lolly Quote  Post ReplyReply Direct Link To This Post Posted: 12 Oct 2011 at 7:40pm
Good observation.  Still mysterious but I will keep that in mind.  They did note that it appeared to them that their calculation was using an exchange rate of 32.000 which gives the same result I listed.  So it may be the format of the field(s) that may account for the issue.
 
And, in answer to your question -- they are accessing the file from the intranet so it would be the same for all.
 
I will keep you updated.
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4116
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 12 Oct 2011 at 8:39pm

A minor syntax error, the line that reads "if (f.value != "");" should not have a ";" at the end of the line.

I would have coded the calculation as follows:
 
var f = this.getField("excRate"); // get exchange rate
var g = this.getField ("Check_Amount"); // get check amount
event.value = ""; // clear field
if (Number(f.value) != 0) {
// divisor not zero
event.value = g.value / f.value; // compute exchange
}
 
If there are other calculations on the form double check the calculation order.
 
have all of the versions of Acrbat/Reader updated?


Edited by gkaiseril - 12 Oct 2011 at 8:43pm
Back to Top
lolly View Drop Down
New Member
New Member


Joined: 15 Jul 2011
Location: US
Points: 5
Post Options Post Options   Quote lolly Quote  Post ReplyReply Direct Link To This Post Posted: 12 Oct 2011 at 8:52pm
I will modify the script.  Thanks.  I have already confirmed the calculation order is correct. 
 
Our international offices have not updated Reader for quite some time but everyone in this office uses the same version (7.0).
Back to Top
lolly View Drop Down
New Member
New Member


Joined: 15 Jul 2011
Location: US
Points: 5
Post Options Post Options   Quote lolly Quote  Post ReplyReply Direct Link To This Post Posted: 13 Oct 2011 at 5:44pm
The issue was caused by the exchange rate's format being text format instead of number format.  Apparently the way the users entered the exchange rate determined whether the calculation was correct or not.  Thank you for your assistance!!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.016 seconds.