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

Auto populate text fields from Drop Down menu

New Here ,
Jun 14, 2025 Jun 14, 2025

Hi,

 

I am completey new to forms. I am trying to create a form with a drop down menu on the left, and 9 text boxes to its right that will each have a different value dependant on what is chosen from the drop down menu. There is a tutorial on YouTube that is explaining essentially the same concept. Yet even when I follow that tutorial to the letter, I have a problem where nothing is showing up in the text fields. The drop down menu works fine, but the text fields do not populate.

 

I have the 'commit selected value immediately' ticked so it isnt that.

Below are screen shots of the initial setup, the code (based on the YouTube tutorial) and the end result

 

Any suggestions are appreciated!

 

Screenshot 2025-06-15 163824.jpg

Screenshot 2025-06-15 163901.jpg

Screenshot 2025-06-15 163930.jpg

   

TOPICS
Create PDFs , How to , JavaScript , Modern Acrobat , PDF , PDF forms
319
Translate
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 15, 2025 Jun 15, 2025

Where did you place script?
If you put script under 'Validate' tab, you need to replace this line:
var dropdownValue = this.getField("JobStep").value;

with:

var dropdownValue = event.value;

Or simply just use: switch(event.value){

Translate
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 15, 2025 Jun 15, 2025

Hi Nisa,

 

the script is in the Calculate tab of the drop down menu

 

Translate
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 15, 2025 Jun 15, 2025

Can you share your file?
EDIT:
You need to use getField not getfield it's case sensitive.

Translate
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 15, 2025 Jun 15, 2025

Hi Nesa,

 

File is attached

Translate
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 17, 2025 Jun 17, 2025
LATEST

So first. Dropdowns are a very popular topic and there are many questions on this forum that are identical to yours. 
Here's one article on how to do this:

 https://acrobatusers.com/tutorials/change_another_field/

And a page that describes how the dropdown works:

https://www.pdfscripting.com/public/List-Field-Usage-and-Handling.cfm

 

You're script is close. But it needs to be written differently and placed in the Custom Validation script for the dropdown.

Here's a simple rewrite:

switch (event.value) {
case "Ensure client inductions / permissions are completed":
    this.getfield("PotentialHazards").value = "Unauthorized work"
    this.getfield("Likelihood").value = "1"
    this.getfield("Consequence").value = "1"
    this.getfield("RiskScore").value = "2"
    this.getfield("Controls").value = "Contact correct site contact for approval"
    this.getfield("Likelihood After").value = "1"
    this.getfield("ConsequenceAfter").value = "1"
    this.getfield("ResidualRisk").value = "2"
    this.getfield("PersonResponsible").value = "All Team Members"
break;
}

 

Since this script will be used in multiple places it would be useful to use table naming for the fields and place the data in an array of objects.  This will massively simplify the scripting, make it more robust, and much easier to maintain over time. 

PM me if you need help. I provide training/consulting on these types of form issues. 

 

 

  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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