Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

round up Javascript in Adobe Acrobat 1

Status
Not open for further replies.

csb1021

Technical User
Apr 14, 2011
8
US
Hello - I need help with writing a javascript to round up a field. I've converted an Excel form to a PDF, and in the Excel form, the code used is: =ROUNDUP(H32, -3)

What I have is 2 fields. One field called Subtotal.1 is the actual total dollars, and the other field called RSubtotal.0 is the 'round up' of Subtotal.1.

Does anyone know what the javascript code would be for this?

Thanks
Connie
 
What is the exact code you used? Where did you place the code?

Based on the names of your fields, this works for me in the 'Calculate' event of the RSubtotal.0 field

event.value = Math.ceil(this.getField("Subtotal.1").value)
 
Hello Mark Walsh

This worked pretty good, however, the owners would like the field to round up - for example, if the Subtotal.1 is $9,144, RSubtotal.0 rounds up to $10,000.00, is this possible?

Thanks Much
Connie Bretes
 
If you're trying to round up to the nearest 1000, then try this:

event.value = Math.ceil(event.value/ 1000) * 1000
 
Hello Mark and others:

Does anyone know if a good book to purchase that covers Adobe Acrobat and Javascripts like what was covered above?
 
There aren't too many books that cover Acrobat javascript, other than the Adobe guides:


These mostly cover the Acrobat-specific context. For more generic Javascript context, there are many books, I have the O'Reilly book:


Also, often when looking for specific context, I just use google to find what I am looking for instead of pulling out the book.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top