Form JavaScript to add text value after drop-down selection

New Here ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

Hi, I'm new to this and need help with a form in Adobe Acrobat Pro DC. 

I created a nomination form where a user can choose an award from a drop-down list named "Type of Award". When a user selects an award, I would like text to populate in text field "Criteria". 
I tried JavaScript examples from other threads and YouTube with no luck. 
Any help would be greatly appreciated. 


TOPICS
Create PDFs, JavaScript, PDF forms

Views

62

Likes

translate

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
Most Valuable Participant ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

- What text? The same one as selected in the drop-down, or something else?

- Should this text be editable by the user, or should it only be determined by the selection in the drop-down?

Likes

translate

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 ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

Thanks for the fast reply.
 

New text that can be edited by the user.


The drop down list "Type of Awards" will have a few options (Service Award, Achievment medal, etc). When a user selects an option, I am hoping text will populate in a text field showing the user what's required for the selected award that can be editable. 


If user selects 'Service Award' then text will populate "Describe achievement in 300 characters or less. I'd like to recognize my employee because..."

 

The user can choose to overwrite completely or add to it. 

Also, if possible, can you help guide me where this code should be added. In Acrobat Pro, I placed the code in the drop-down list properties Action tab as a  mouse exit event. Reading other threads mention to place in a validation box that's now confusing. 

Likes

translate

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
Most Valuable Participant ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

As the custom validation script of the drop-down field enter this:

 

if (event.value=="Service Award") this.getField("Criteria").value = "Describe achievement in 300 characters or less. I'd like to recognize my employee because...";

 

Duplicate the line for each value.

Likes

translate

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 ,
Mar 05, 2021 Mar 05, 2021

Copy link to clipboard

Copied

Yeah! Worked on first try. thank you thank you

 

Saving this code in a safe place.

 

Will this work on radio buttons too?

Likes

translate

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
Most Valuable Participant ,
Mar 05, 2021 Mar 05, 2021

Copy link to clipboard

Copied

Radio buttons don't have a validation event, but you can use the Mouse Up event, instead.

However, the value should be accessed then using event.target.value instead of just event.value.

Likes

translate

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