Skip to main content
Participant
May 3, 2023
Question

Script not working to have second drop down populate from first drop down selection

  • May 3, 2023
  • 1 reply
  • 242 views

var productChild = this.getField("Product Child");
var productParentValue = this.getField("Product Parent").value;

// Clear the options in the Product Child drop-down list
productChild.clearItems();

// Add the options based on the selected value in the Product Parent drop-down list
if (productParentValue == "1") {
productChild.addItem("Option 1a", "Option 1a");
productChild.addItem("Option 1b", "Option 1b");
} else if (productParentValue == "2") {
productChild.addItem("Option 2a", "Option 2a");
productChild.addItem("Option 2b", "Option 2b");
} else if (productParentValue == "3") {
productChild.addItem("Option 3a", "Option 3a");
productChild.addItem("Option 3b", "Option 3b");
}

 

Can anyone help with this code? I've tried everything I know how do to do.  thank you!!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
May 3, 2023

There's no such method as "addItem". You can use insertItemAs to insert a single item to an existing drop-down's list (but read the documentation of how it should be used!), or setItems to set the entire list.