Skip to main content
Participant
June 14, 2024
Answered

List specific items in LB2 by the choice of LB1.

  • June 14, 2024
  • 1 reply
  • 297 views

Hi

In Adobe Pro, I want to create a form with two list boxes. The second box should display specific items based on the selections made in the first box, allowing multiple choices to be selected from the first box. 

Also, I want the items that chosen alone be visible. 

This topic has been closed for replies.
Correct answer Nesa Nurani

Try something like this as 'On Blur' action of "List Box1" field:

var L2 = this.getField("List Box2");
var cList2 = [];
var v = event.target.value;

if (typeof v === "object" && v !== null) {
 for (var i=0; i<v.length; i++) {
  if (v[i] === "Fruits")
   cList2.push("Banana", "Orange", "Apple");       
  if (v[i] === "Vegetables")
   cList2.push("Rice", "Carrot");}}

// If only one item is selected
else if (typeof v === "string") {    
 if (v === "Fruits")
  cList2.push("Banana", "Orange", "Apple");
 else if (v === "Vegetables")
  cList2.push("Rice", "Carrot");}

L2.clearItems();
L2.setItems(cList2);

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
June 14, 2024

Try something like this as 'On Blur' action of "List Box1" field:

var L2 = this.getField("List Box2");
var cList2 = [];
var v = event.target.value;

if (typeof v === "object" && v !== null) {
 for (var i=0; i<v.length; i++) {
  if (v[i] === "Fruits")
   cList2.push("Banana", "Orange", "Apple");       
  if (v[i] === "Vegetables")
   cList2.push("Rice", "Carrot");}}

// If only one item is selected
else if (typeof v === "string") {    
 if (v === "Fruits")
  cList2.push("Banana", "Orange", "Apple");
 else if (v === "Vegetables")
  cList2.push("Rice", "Carrot");}

L2.clearItems();
L2.setItems(cList2);