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?
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.
Actually, the duplicate field name thing is intentional. I want the value to be copied throughout the newly created file.
My question is regarding the java, not the duplicate fields--unless you think the duplicate fields is causing the java problem, of course.
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.