Copy link to clipboard
Copied
Thanks for taking the time to read my question.
I can't seem to figure out how to set a Tex Fields default value to the current date. Is there a way to do this?
Thanks,
Brad
Copy link to clipboard
Copied
No, because the script will only get triggered when some other field value changes. It will not update when the document is opened until the user changes some field value.
Copy link to clipboard
Copied
Do you want the date updated every time the document is opened, or something else?
Copy link to clipboard
Copied
Sorry I thought everyone could read my mind.... lol . When the doc is opened, place today's date in the "TodaysDate" field.
I'm continuing to search the interweb and I'm thinking about doing something with the Calculate on the text field's properties??
Brad
Copy link to clipboard
Copied
Just set the value of the field directly. Place the following code in a document-level JavaScript, outside of a function definition. It will execute every time the document is opened:
getField("date_field").value = util.printd("yyyy-mm-dd", new Date());
You can use whatever format you want. More details here: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
Copy link to clipboard
Copied
Thanks George,
I've seen some posts about placing code in a document-level JavaScrip... I just can't figure out how to get there.
Some posts talk about the Advanced menu. I don't have that. I'm using a trial version to see if Acrobat Pro can do what we need it to do. If it can, we'll buy it. Need to test and prove before mgt will approve the purchase though.
http://en.allexperts.com/q/Adobe-Acrobat-2186/Auto-filling-date-field.htm
http://65.181.155.238/forum/forms-acrobat/default-date-form-question
Thanks for the link. very helpful!
Brad
Copy link to clipboard
Copied
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/Acro6JSGuide.pdf
Page 55 explains how to do this as well. Just don't have the Advanced menu option.
Brad
Copy link to clipboard
Copied
If you're using Acrobat 10, select the Tools panel, and then "JavaScript > Document JavaScripts". Add a new one, remove the function skeleton it provides automatically, and enter the code shown above. Replace the field name with your actual field name.
Copy link to clipboard
Copied
I just put
var f = this.getField("Today");
f.value = util.printd("mm/dd/yyyy", new Date());
In the Custom calculation script: field under the Calculate tab for the properties for the text field and it seems to work now... Is that the best way to do it?
Brad
Copy link to clipboard
Copied
No, because the script will only get triggered when some other field value changes. It will not update when the document is opened until the user changes some field value.
Copy link to clipboard
Copied
Outstanding!
Thank you so very much for your help George.
Have a great day.
Brad

