Dependent drop down list - I have seen many questions and answers but i can not get the code to work

New Here ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

I am trying, like many others have on here, to get a dropdown list to appear dependent on another dropdown.  I have tried reading the forum and taking the code to use in my form but I can not get it to work properly.  I ma obviously out of my depth.  Can anyone please be of some assitance?  My initial dropdown box has 25 options, based upon their selection it should open up a specific set of responses in another dropdown.  

 

The first box's name is Potential Hazards, the dependent dropdown is Control Measures.  When the Potential Hazards has a selection of say Pinch Points, the Control Measure box should have a drop down box with a selection for PPE, Manpower, Proper Clearance, etc.  With some guidance I can extrapolate the remaining code.

 

A second thing that I would like to have is when a selection is made, dependent on the choice, a generic text comment can be put into another box.  Using the Potential Hazards example, if I selecet Pinch Points, I would like a generic comment installed into another box stating "Ensure all PPE and safety precautions are taken".  

 

Any and all help is greatly appreciated.  

 

 

Jason

TOPICS
Create PDFs , How to , PDF forms

Views

79

Likes

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
Adobe Community Professional ,
May 02, 2022 May 02, 2022

Copy link to clipboard

Copied

 Lets say that text field is called "Info" as 'Validation' script of  "Potential Hazards" use this:

var f = this.getField("Control Measures");
var txt = this.getField("Info");
switch(event.value){
case "Pinch Points":
f.setItems(["PPE", "Manpower", "Proper Clearance"]);
txt.value = "Ensure all PPE and safety precautions are taken";
break;

default:
f.clearItems();
txt.value = "";}

 

In "Potential Hazards" dropdown field in options tab check "Commit selected value immediately".

 

Likes

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 ,
May 03, 2022 May 03, 2022

Copy link to clipboard

Copied

Outstanding, that works great.  I can now modify the dependent drop down as needed.  One last question, hopefully;  In my potential hazards dropdown I have a selection of 20 or so options which should each bring up their pwn drop down in the control measures box.  How do I add a second option to the hazards drop down?  

 

var f = this.getField("Control Measures");
var txt = this.getField("Info");
switch(event.value){
case "Pinch Points":
f.setItems(["-Select your control measure-","PPE", "Manpower", "Proper Clearance"]);
txt.value = "Ensure all PPE and safety precautions are taken";
break;

default:
f.clearItems();
txt.value = "";}

 

In other words, how do I tranistion, or add the next selection after "pinch points"?  We can use "Arc Flash" as an example with control measure of  "wear glasses".  I can probably figure the rest out from there.  

 

Fingers crossed. 

 

Thanks again, 

Jason

Likes

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
Adobe Community Professional ,
May 03, 2022 May 03, 2022

Copy link to clipboard

Copied

Add line between 'break' and 'default' like this:

var f = this.getField("Control Measures");
var txt = this.getField("Info");
switch(event.value){
case "Pinch Points":
f.setItems(["-Select your control measure-","PPE", "Manpower", "Proper Clearance"]);
txt.value = "Ensure all PPE and safety precautions are taken";
break;

case "Arc Flash":

f.setItems(["-Select your control measure-","PPE", "Manpower", "Proper Clearance"]);
txt.value = "Ensure all PPE and safety precautions are taken";

break;

default:
f.clearItems();
txt.value = "";}

Of course change 'f.setItems' and 'txt.value' to whatever you want.

 

Likes

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 ,
May 03, 2022 May 03, 2022

Copy link to clipboard

Copied

LATEST

Works like a charm.  Thank you.

Likes

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