×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

round up Javascript in Adobe Acrobat

round up Javascript in Adobe Acrobat

round up Javascript in Adobe Acrobat

(OP)
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

RE: round up Javascript in Adobe Acrobat

Math.ceil(1.1)

will round up to 2

RE: round up Javascript in Adobe Acrobat

(OP)
I tried this and it didn't work????

RE: round up Javascript in Adobe Acrobat

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)

RE: round up Javascript in Adobe Acrobat

(OP)
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

RE: round up Javascript in Adobe Acrobat

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

event.value = Math.ceil(event.value/ 1000) * 1000

RE: round up Javascript in Adobe Acrobat

(OP)
Hello Mark and others:

Does anyone know if a good book to purchase that covers Adobe Acrobat and Javascripts like what was covered above?  

RE: round up Javascript in Adobe Acrobat

There aren't too many books that cover Acrobat javascript, other than the Adobe guides:

http://partners.adobe.com/public/developer/en/acrobat/sdk/AcroJSGuide.pdf
http://partners.adobe.com/public/developer/en/acrobat/sdk/AcroJS.pdf

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

http://www.amazon.com/gp/product/0596101996/ref=pd_lpo_k2_dp_sr_1?pf_rd_p=486539851&pf_rd_s=lpo-top-stripe-1&pf_rd_t=201&pf_rd_i=0596000480&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=1KK8E1XBNSMFR5J6WZXQ

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close