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

Superscript "$" and cents returning Zero value

whitewolf68
Registered: Jan 8 2011
Posts: 3

I've tried to implement the javascript suggested by George Kaiser in thread:
 
http://acrobatusers.com/forum/javascript/setting-and-cents-currency-format-superscript
 
with no luck at all.
 
For instance if I type 19.99 it will display $0.00 instead of $19.99. If I select the field to edit it will show the field value of 19.99 but when I hit enter reverts back to $0.00.
 
Any ideas how I can fix this? I've been fighting with it for weeks now trying to find a cure or a cause with no luck.
 
Any help you can provide is greatly appreciated.
 
Thank you,
 
Andrew

My Product Information:
Acrobat Pro 9.4, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Exactly what code are you using in what event? And what kind of form, LiveCycle or AcroForm?

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

whitewolf68
Registered: Jan 8 2011
Posts: 3
Hi Thom,

Sorry if I was a bit vague. I am using Acrobat 9 and created the PDF in whole there. What was happening was that the PDF was not retaining the Rich Text Field setting for the price input field. Some how I had a spark of intelligence and started my code with

var f=this.getField("Price 1")
f.richText = true;

That cured the problem that's been plaguing me for weeks.

During the process it was working ONLY if I went into the field and clicked off RTF and back on again. It worked up until I saved it, closed it out and re-opened it. No matter the price I entered the script was returning $0.00 after I opened it again.

Here is the script I used to finally get it all working 100%.

var f=this.getField("Price 1")
f.richText = true;
var spans = new Array();
spans[0] = new Object(); spans[0].text = "$";
spans[0].superscript = true;
var fDollars = Math.floor (event.value);
spans[1] = new Object();
spans[1].superscript = false;
spans[1].text = util.printf("%.0f", fDollars);
var fCents = event.value % 1;
fCents *= 100;
spans[2] = new Object();
spans[2].superscript = true;
spans[2].text = util.printf ("%02.0f", fCents);
event.richValue = spans;

I thank you for your response and look forward to more help from you and others here in the community.