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

Strange NaN

kmay
Registered: Mar 18 2010
Posts: 18

Hi All

I have a form that I thought was working - wrong!

It is the simplest of calculations QTY x UNIT PRICE = Total Amount

if the price is less than 3 digits, there is no issue, if the unit price is more than 4 digits - I get a NaN in the Total Amount field.

now the quotation form can either be in dollars, Pounds or Euros (depending on what is selected in a combo box), so the Custom format script I have on the Total Amount field is this:

if (this.getField("Currency").value == "USD $" ){ 
AFNumber_Format(2, 0, 0, 0,"$", true)};
 
if (this.getField("Currency").value == "GBP £" ){ 
AFNumber_Format(2, 0, 0, 0,"£", true)};
 
if (this.getField("Currency").value == "EUR €" ){ 
AFNumber_Format(2, 0, 0, 0,"€", true)};
 
if(event.value == "$0.00") event.value = '';
if(event.value == "£0.00") event.value = '';
if(event.value == "€0.00") event.value = '';

The actual calculation is just the built in calculation 'value is the product of...'.

Any ideas what I have done wrong?

thanks :)

kmay
Registered: Mar 18 2010
Posts: 18
this is a shameless bump. Does anyone have any idea why my forms don't like multiplying things in the thousands? Thanks!
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Could you post the file?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

kmay
Registered: Mar 18 2010
Posts: 18
Hi Try67, is there a place to attach files or do I need to upload it myself.. I'm possibly missing something very obvious! Thanks
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You need to upload it yourself. You can use Acrobat.com or some free hosting site like rapidshare.com

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

kmay
Registered: Mar 18 2010
Posts: 18
Thanks Try67

It's uploaded to rapidshare. I have removed the background/company logos and other fields.

It's currently acting very strange, it sometimes does the first calculation (with a 4 digit unit price) but freaks out if I type in another 4 digit unit price on the next line and so on, hopefully it will be clear when you see the document..

http://rapidshare.com/files/378422725/pdf.pdf.php

I realise this form is quite messy with some formatting in the 'custom format' sections and some in the 'custom calculations' sections - my reasoning for that was if the user fills in the form, realises they didn't select the correct currency and changes it then, it doesn't change the format of many of the cells (the ones that don't have an actual calculation applied to them stay with whatever currency was first selected)

I hope that makes sense. Please let me know if I can explain it better.

For now, to get around it, I've just removed all formatting from the 'unit price' section although ideally I would prefer this could be formatted with the currency sign as well.

thanks!
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Have you checked the order of your calculated fields?

It appears you are calculating the "Total" field for each row before you calculate the 'PriceUnit" for that row.

George Kaiser

try67
Expert
Registered: Oct 30 2008
Posts: 2398
I think the problem is with the way you use AFNumber_Format(). From looking at the code of this function, it seems to me that it will only format event.value, which in your case is always empty since this field (Freight & Insurance) should be calculated, not manually entered by the user, if I understand correctly.
I think you should reconsider the way you calculate the value for this field.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com