Skip navigation
Currently Being Moderated

Combining Forms, where to put the Javascript code?

Jul 18, 2012 2:01 PM

Tags: #javascript #forms #combining

I have several forms I combine into a single PDF.  Several form fields are identical in each file.  I use Javascript to populate some of the data such as the current Date and Current Time.

 

After combining the files, however, the javascript is completely gone.

 

Here's what I use:

 

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

getField("TimeNow").value = util.printd("h:MM tt", new Date())

 

I have it placed in the "Document will Print" section under "Documenet Actions".

 

Where do I put my code so that it doesn't get wiped out when i combine the files?

 
Replies
  • Currently Being Moderated
    Jul 18, 2012 2:12 PM   in reply to Neil-Kentucky

    If you look closer, you will see more than your code being lost.

     

    Form fields with the same name share many common properties. The more important of which for a text field is the value of the field. That means if there are more than one text field with the same name, the value of any one of the fields with the same name will have the same value.

     

    With Acrobat forms, if you want to have multiple copies of the same form within one PDF you need to have each field uniquely named. Usually many will prefix the field name with the value "p" + the zero based page number. You will have to adjust all your scripts to adjust for this prefix.

     

    A Lesson in Templates for Adobe Acrobat

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 18, 2012 2:32 PM   in reply to Neil-Kentucky

    The JavaScript is part of the field, so if you combine two documents with the same named field, you only end up with one field. It might be the one with the JavaScript, or it might not.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 18, 2012 3:42 PM   in reply to Neil-Kentucky

    Which document action?

     

    There is a "Document" scripts wiith Acrobat Professional and when a script is located there, the script apples to all pages and actions within the PDF and for any code that is subject to reuse or used to initialize the form.

     
    |
    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