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

Autopopulate a Field On Focus/Click

New Here ,
Oct 20, 2022 Oct 20, 2022

I'm hoping someone here is able to offer me a solution, if one even exists.

I am creating on online form, and I'd like to find a way to automate the population of a particular field on the form.

I am hoping it's possible, with some support from the pros here, that on a click of a field (time) that the field can automatically be cpopulated with the current time. COnsider also, that this form will be filled out on a mobile device, so perhaps a tap would be the same as a click in the field?

TOPICS
How to , PDF forms
1.3K
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
2 ACCEPTED SOLUTIONS
Community Expert ,
Oct 20, 2022 Oct 20, 2022

This should work on mobile Acrobat reader, use as 'On Focus':

event.target.value = util.printd("HH:MM", new Date())

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 ,
Oct 20, 2022 Oct 20, 2022

To populate the second field (let's call it "time2") add this to the script:

this.getField("time2").value = event.target.value;

But I'm not sure if setting a field to read only can be done on mobile.

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 ,
Oct 20, 2022 Oct 20, 2022

It depends from browser to browser but you my have trouble using JavaScript, especially on mobile where it's not even supported much.

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 ,
Oct 20, 2022 Oct 20, 2022

Unfortunately no. The problem is that there are a large number of PDF viewers, and very few of them support the necessary PDF JavaScript. To do this you need to have a way to control where the user opens the PDF.     

 

 

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
New Here ,
Oct 20, 2022 Oct 20, 2022

Thank you all.

The users, on mobile, would most certainly be expected to use Adobe Reader (the mobile version). It is the only PDF reader permitted and installed on their devices. Does this help?

I will be posting more "can I" type questions as I pursue the appropriateness of using Adobe forms for my needs. If I get too many "not possibles", I will have to go down a road of deeper unknowns lol.

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 ,
Oct 20, 2022 Oct 20, 2022

Yes, that helps a lot. I am not totally certain, but the Adobe Mobile Reader should work. However I would not count on this working on a browser PDF viewer. 

 

 

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
Community Expert ,
Oct 20, 2022 Oct 20, 2022

This should work on mobile Acrobat reader, use as 'On Focus':

event.target.value = util.printd("HH:MM", new Date())

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 ,
Oct 20, 2022 Oct 20, 2022

Thank you both Thom and Nesa. Nesa, thank you for providing the solution. Javascript is not code I'm familiar with unfortunately so the guidance (dare I say hand holding) is greatly appreciated.

If I can expand on this ,,,

After the field has been populated, how can I make that field read only?

and ..

How can I autopopulate a second form field with that same 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
Community Expert ,
Oct 20, 2022 Oct 20, 2022

To populate the second field (let's call it "time2") add this to the script:

this.getField("time2").value = event.target.value;

But I'm not sure if setting a field to read only can be done on mobile.

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 ,
Oct 21, 2022 Oct 21, 2022
LATEST

Thank you Nesa.

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