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

Load default text in a field when opening a form

New Here ,
Jun 21, 2024 Jun 21, 2024

Copy link to clipboard

Copied

Hello, I have not developed forms in Adobe for quite a long time due to a career change.  Well, I am back at it again and something thats seems very simple is proving to be frustrating.  Basically, I would like a text field to auto-populate everytime  the form is opened.  I have attempted to input a default text in the field, but when the default text is deleted it dosent repopulate when I open the form again.  Basically, 95% of the time i want the field to populate with the default test, but the remaining 5% of the time I would like to enter different text from the default text.

 

For example...... 95% of the time I would like the text to read "Dog" when I open the document, but in the off chance I want the field to say"Cat" I would like to edit that field. But..... the next time the form is opened I want it to default to "Dog" again.  

 

Currently, when I open the document "Dog " will show in the field, but if I delete dog and close the form the field does not auto populate again even though "Dog" is still the default text in the options menu.

TOPICS
Create PDFs , Edit and convert PDFs , PDF forms

Views

144

Translate

Translate

Report

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 ,
Jun 21, 2024 Jun 21, 2024

Copy link to clipboard

Copied

To populate field when document open, use script as 'Document level JavaScript', something like this:

this.getField("Field name").value = "Dog";

Votes

Translate

Translate

Report

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 ,
Jun 21, 2024 Jun 21, 2024

Copy link to clipboard

Copied

My apoligies, if I sound like a bit of a newbie here as its been over 10 years since I have done this.  Would I place this script in the "actions" tab of the field properties?

Votes

Translate

Translate

Report

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 ,
Jun 21, 2024 Jun 21, 2024

Copy link to clipboard

Copied

No, you place it at 'Document level', select 'Prepare form' tool then click on 'More' and select 'Document JavaScript', give script a name and click 'add' then place script there and save.

EDIT: you can also select 'Document JavaScript' tool.

Votes

Translate

Translate

Report

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 ,
Jun 21, 2024 Jun 21, 2024

Copy link to clipboard

Copied

That worked well.  Thank you.  Another question is you dont mind.  When the field is changed and I save a copy "completed form" and reopen the saved form it deletes all of my input and defaults back to the default.  is there a way to make the edited field stay when the end user does need to edit and save the form?

Votes

Translate

Translate

Report

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 ,
Jun 21, 2024 Jun 21, 2024

Copy link to clipboard

Copied

Change the code to:

if (this.getField("Field name").value=="") this.getField("Field name").value = "Dog";

Votes

Translate

Translate

Report

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 ,
Jun 21, 2024 Jun 21, 2024

Copy link to clipboard

Copied

LATEST

THAT WORKED... THANK YOU

Votes

Translate

Translate

Report

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