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.
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";
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.
Copy link to clipboard
Copied
Change the code to:
if (this.getField("Field name").value=="") this.getField("Field name").value = "Dog";
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";
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?
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.
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?
Copy link to clipboard
Copied
Change the code to:
if (this.getField("Field name").value=="") this.getField("Field name").value = "Dog";
Copy link to clipboard
Copied
THAT WORKED... THANK YOU