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

javascript for filling text box with value from dropdown list

New Here ,
Feb 27, 2023 Feb 27, 2023

Copy link to clipboard

Copied

I am needing a javascript to have text populate in a seperate text filed when a selection is made from a dropdown box.  I am new and not even sure how to imput the javascript once I have it.  Please help!  This is for a Fillable PDF I am trying to create.  In the document I am trying to have the selection from dropdown box labeled "Class" on page 1, to auto populate the text from drop donw box "Allocation Factor I" on page 2, but in a text filed.  Example.  you select "Rehabilitation Representative" from page one, you get "The Rehabilitation Representative classification represents an entry-level scope of couseling skills and limited decision-making authority. Work is closely monitored." in a text box instead of what I currently have as another dropdown box.  Thanky ou in advance for your help!

TOPICS
How to , JavaScript , PDF forms

Views

3.1K

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 ,
Feb 27, 2023 Feb 27, 2023

Copy link to clipboard

Copied

Do you want the user to be able to edit this text, or should be determined solely based on the selection in the drop-down?

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 ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

unable to edit.  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
Community Expert ,
Mar 01, 2023 Mar 01, 2023

Copy link to clipboard

Copied

Change the second field to a text field, and use the following code as its custom Calculation script:

 

var vClass = this.getField("Class").valueAsString;
if (vClass=="Select one") event.value = "";
else if (vClass=="Rehabilitation Representative") event.value = "The Rehabilitation Representative classification represents an entry-level scope of couseling skills and limited decision-making authority. Work is closely monitored.";
else if (vClass=="Rehabilitation Counselor, Senior") event.value = "Text for: Rehabilitation Counselor, Senior";
else if (vClass=="Rehabilitation Counselor, Career") event.value = "Text for: Rehabilitation Counselor, Career";

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
Explorer ,
Mar 13, 2023 Mar 13, 2023

Copy link to clipboard

Copied

This is super helpful, thanks for posting this. I am a n00b as well and am trying to do something similar. I have a dropdown box with a list of items. I want a user to select an item and have an output to a standard text box. Example" user selects "item 1" from dropdown box1 and a representative number, say "10", is output in textbox 1. I'm banging my head against the wall. Any guidance would be most appreciated. Thanks in advance!

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 ,
Mar 28, 2024 Mar 28, 2024

Copy link to clipboard

Copied

I tried this coding in my file, but instead of "Rehabilitation Representative", I changed it to what I'm using to "Wedding Reception".  It didn't work.  I'm not understanding the basic function... do I put the coding in the text box, or the dropdown box?  Do I need to select Wedding Reception in the dropdown box when in Prepare A Form setting, and if so, how do I assign Wedding Reption to that specific code to appear in a separate text box?  I have five different items in the dropdown menu, and don't understand javascript at all to know how to assign the five items to have uniquely different descriptions in the one text box.  Can anyone help?

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 ,
Mar 28, 2024 Mar 28, 2024

Copy link to clipboard

Copied

LATEST

The script posted above should go to text field as 'Custom calculation script'.

If you look at the script you will see where you need to put description, for example in this line:

else if (vClass=="Rehabilitation Counselor, Senior") event.value = "Text for: Rehabilitation Counselor, Senior";

else if (vClass=="Rehabilitation Counselor, Senior")//here you compare selection from dropdown field if you selected "Rehabilitation Counselor, Senior" in dropdown field,  text field will show "Text for: Rehabilitation Counselor, Senior"

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 ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

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