Skip to main content
Known Participant
September 5, 2023
Answered

Multi Level Dependable Dropdown and Text Field

  • September 5, 2023
  • 3 replies
  • 450 views

Hi! Experts, 

I am creating a PDF Fillable Form. I created a Dependable Dropdown it's working using the below code 

First Dropdown Name: "Tile"

Second Dropdown Name: "Condition"

 

This code is pasted in First Dropdown "Tile"

 

var f = this.getField("Condition");
switch(event.value){

case "Terracotta":
f.setItems(["lichen"]);
break;

case "Concrete Tiles":
f.setItems(["Acceptable","Fair","Poor","Mould","Moss" ]);
break;

case"-Select-":
f.clearItems();}

 

its create dropdown items in 2nd dropdown. 

 

NOW I want to auto-populate the Description based on 2nd dropdown selected in 

Third Field Name: "Description"

 

For Exemple:

in 2nd dropdown "Acceptable" Selected it auto populate description in "Description" field and so on. 

Kindly Help me out. 

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer try67

You can use something like this:

 

var tile = this.getField("Tile").valueAsString;
var condition = this.getField("Condition").valueAsString;
if (tile=="Concrete Tiles" && condition=="Acceptable") event.value = "The concrete tiles are in acceptable condition.";
else if (tile=="Concrete Tiles" && condition=="Fair") event.value = "The concrete tiles are in fair condition. Further inspection is required.";
// etc.

3 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 5, 2023

You can use something like this:

 

var tile = this.getField("Tile").valueAsString;
var condition = this.getField("Condition").valueAsString;
if (tile=="Concrete Tiles" && condition=="Acceptable") event.value = "The concrete tiles are in acceptable condition.";
else if (tile=="Concrete Tiles" && condition=="Fair") event.value = "The concrete tiles are in fair condition. Further inspection is required.";
// etc.
Hafiz79Author
Known Participant
September 5, 2023

Image for reference

 

Thom Parker
Community Expert
Community Expert
September 5, 2023
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often