Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Set Text Field Default Value Current Date

New Here ,
Dec 03, 2010 Dec 03, 2010

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

42.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
LEGEND ,
Dec 03, 2010 Dec 03, 2010

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.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 03, 2010 Dec 03, 2010

Do you want the date updated every time the document is opened, or something else?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 03, 2010 Dec 03, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 03, 2010 Dec 03, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 03, 2010 Dec 03, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 03, 2010 Dec 03, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 03, 2010 Dec 03, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 03, 2010 Dec 03, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 03, 2010 Dec 03, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 03, 2010 Dec 03, 2010
LATEST

Outstanding!

Thank you so very much for your help George.


Have a great day.

Brad

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines