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

Prepopulating a field

Participant ,
Jul 03, 2023 Jul 03, 2023

I have a form in which I want to prepopulate a field. Specifically load it with today's date. I have written a "document script" which does this. When the document loads, it works, but after doing a "reset form", it doesn't. What I find frustrating is that I have another form in which this works perfectly but I can't find the difference.

 

Any thoughts?

TOPICS
PDF forms
508
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
Community Expert ,
Jul 03, 2023 Jul 03, 2023

Here's a shorter script;

 

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

 

Since this is a document script, it only runs when the PDF is opened. For the field to automatically populate on a reset it would need to be a script on the reset button. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Community Expert ,
Jul 03, 2023 Jul 03, 2023

You'd need to post the form so we could look at it.

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Participant ,
Jul 03, 2023 Jul 03, 2023

I'm a bit uncomfortable posting the entire form. Here is the field:

 

Jack157F_1-1688433911400.png

And here is the javascript:

 

var today = new Date();
var yyyy = today.getFullYear();
mm = today.getMonth() + 1; // Months start at 0!
dd = today.getDate();

if (dd < 10) dd = '0' + dd;
if (mm < 10) mm = '0' + mm;

var today = mm + '/' + dd + '/' + yyyy;
vsigdate=getField("Signature Date").value=today

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
Community Expert ,
Jul 03, 2023 Jul 03, 2023

Here's a shorter script;

 

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

 

Since this is a document script, it only runs when the PDF is opened. For the field to automatically populate on a reset it would need to be a script on the reset button. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Participant ,
Jul 03, 2023 Jul 03, 2023
LATEST

Thank you. I don't know how I missed it.

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