Copy link to clipboard
Copied
I have utilized a java script to insert an automatic date/timestamp field in a PDF. I was successful in doing that but it saved the form with the date/time. I want this to be blank each time it's opened and insert the date/time when someone has to fill out the form.
Copy link to clipboard
Copied
Where did you place the code? What triggers it?
Copy link to clipboard
Copied
It's within Page Properties, Actions (Select a Java Script)
Copy link to clipboard
Copied
You need to move it to be a doc-level script, so that it only runs when the file is opened.
Place it under Tools - JavaScript - Document JavaScripts to achieve that. Do NOT place the code in a function, though.
Copy link to clipboard
Copied
Thanks for your help with this. I tried that and it still did the same thing. Do I place in Document JavaScripts or All JavaScripts?
Copy link to clipboard
Copied
Document JavaScripts.
What do you mean by "the same thing", exactly?
After you apply the code, clear the form and then save the file and close it. Then the field will be populated the next time you open it.
Copy link to clipboard
Copied
It saves the date/time even though I clear if off and save. When I open the file again, it has a previous time on it.
Copy link to clipboard
Copied
Post your code, and/or your file, please.
Copy link to clipboard
Copied
var f = this.getField("Date/Time");
f.value = util.printd("m/d/yyyy h:mm tt", new Date());
Where does it pull the time from? Now it is inserting the time five minutes ahead of the time showing on my pc.
Copy link to clipboard
Copied
No, it's not doing that. It's showing the current month instead of the minutes, though...
Change it to:
f.value = util.printd("m/d/yyyy h:MM tt", new Date());
Copy link to clipboard
Copied
Ok, I tried that and it didn't insert the date or time.
Copy link to clipboard
Copied
Does it need to be placed under Document JavaScripts?
Copy link to clipboard
Copied
Yes
Copy link to clipboard
Copied
I think I finally got this to work correctly! Thanks to all for your help on this!!
Copy link to clipboard
Copied
Copy-paste this URL in Google Translate to see a nice tuto and get a nice sample file that will answer your question:
Copy link to clipboard
Copied
ok thanks, I will take a look.
Copy link to clipboard
Copied
When I place it under Tools - JavaScript - Document JavaScripts it adds the pull down as pictured below. I do not want it to do that. It needs to auto fill the date / time when a person opens it.
Copy link to clipboard
Copied
Set the field as Read-Only.