Skip navigation
sheri@magillhr.com
Currently Being Moderated

How do I auto populate the date into text fields when form is first opened?

Sep 27, 2012 7:37 AM

Tags: #acrobat_9_forms

Hello,

 

I read all about the changing the scripts but its not really working for me. I was hoping someone could help me with directions on how to auto populate the date into designated text fields when my adobe document is first opened?

 

I am working in Adobe Acrobat 9.

 

Thank you,

Sheri

 
Replies
  • George Johnson
    11,671 posts
    Aug 11, 2002
    Currently Being Moderated
    Sep 27, 2012 10:04 AM   in reply to sheri@magillhr.com

    At it's simplest, you can use the following code in a document-level JavaScript, outside of a function definition:

     

    getField("date1").value = util.printd("mm/dd/yyyy", new Date());

     

    It will execute when the document is opened and update the field's value. It can be refined to only populate when the field is empty, preventing it from getting overwritten on subsequent openings after it's initially set and saved.

     
    |
    Mark as:
  • George Johnson
    11,671 posts
    Aug 11, 2002
    Currently Being Moderated
    Sep 27, 2012 10:33 AM   in reply to sheri@magillhr.com

    When you add a new document JavaScript (Advanced > Document Processing > Document JavaScripts > Script Name (enter something) > Add), you will be given a function skeleton by default. Just delete it and enter the line of code I showed above. Now, whenever the document is opened, the code will get triggered and the field will be updated with the current date. There is no "Document Open" action (at least that's accessible via Acrobat's UI), but this is effectively the same thing since any document-level JavaScripts are executed when the document is opened.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points