Skip to main content
New Participant
February 27, 2023
Question

javascript for filling text box with value from dropdown list

  • February 27, 2023
  • 2 replies
  • 4416 views

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!

This topic has been closed for replies.

2 replies

JR Boulay
Community Expert
February 28, 2023
Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
February 27, 2023

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?

New Participant
February 28, 2023

unable to edit.  Thank you

try67
Community Expert
March 1, 2023

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";