Skip to main content
Participating Frequently
October 20, 2022
Answered

Autopopulate a Field On Focus/Click

  • October 20, 2022
  • 2 replies
  • 1410 views

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?

This topic has been closed for replies.
Correct answer Nesa Nurani

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?


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.

2 replies

Thom Parker
Community Expert
Community Expert
October 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 PDFScriptingUse the Acrobat JavaScript Reference early and often
Jenn MC2Author
Participating Frequently
October 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.

Thom Parker
Community Expert
Community Expert
October 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 PDFScriptingUse the Acrobat JavaScript Reference early and often
Nesa Nurani
Community Expert
Community Expert
October 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.