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

Acrobat 9 Number Formatting Problem

emagin
Registered: Sep 6 2011
Posts: 2

Hello Everyone,
 
I am creating an interactive invoice in Acrobat 9 and have a bit of a problem with one of the number fields. I have it set so that the user can enter the quantity and the cost/item and have it calculate the total, which is fine in the fields that have this information. The problem is when the quantity and cost/items fields are empty, the total column lists a 0. I would like that field to be blank.
 
How do I make this happen?

Khalid Muhammad
Group Managing Director
emagine group

My Product Information:
Acrobat Pro 9.0, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The only way to do this is to use a custom format script. You'll find some examples here

http://acrobatusers.com/tutorials/2006/formatting_text_fields

In your case the code will need to format for two conditions, the dollar amount and blank. The easiest condition to test for is a 0 calculation result, but you could also detect blank input values as well. Here's an example Format Script


if(event.value == 0)
event.value = "";
else
event.value = util.printf("$%,02.2f",event.value);

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

emagin
Registered: Sep 6 2011
Posts: 2
thomp wrote:
The only way to do this is to use a custom format script. You'll find some examples herehttp://acrobatusers.com/tutorials/2006/formatting_text_fields

In your case the code will need to format for two conditions, the dollar amount and blank. The easiest condition to test for is a 0 calculation result, but you could also detect blank input values as well. Here's an example Format Script


if(event.value == 0)
event.value = "";
else
event.value = util.printf("$%,02.2f",event.value);
Hey Thomp,

Thank you for the reply. I was unable to open the link that was included with your post, but I have a followup question. Since I am new to JavaScripting in Acrobat, I am not sure how to include the calculation that goes with it.

If my quantity field is quant.1 and the cost field is cost.1 - how would the whole script look?

Much appreciation in advance for the assistance!

Khalid Muhammad
Group Managing Director
emagine group

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I noticed this morning that the articles weren't coming up. I tried a bunch, so it seems like a site wide issue. I was hoping that it would be short term:(

emagin wrote:
Since I am new to JavaScripting in Acrobat, I am not sure how to include the calculation that goes with it.

That answer is in the articles on this site was well:(

Here is a link to some videos that should be very helpful. And I know they are working
Free Videos at pdfscripting.com

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