Conditional Drop Down on Script

Hi, I would like to know if it is possible to create a conditional drop down list in scripts?
my idea is I have 2 Drop down selection and the values on the 2nd drop down should be dependent on the selection on the 1st drop down? like a link drop down list. something like this if I select Category 1 in the 1st drop down the 2nd drop down should show the sub-category list for Category 1 only. and so on... is this doable?
image

Hello,

I had a similar use case and here is how I did it.
It requires Data Actions and Data Table.

You can hard code the first DropDown list with the Categories.
You load all the Subcategories in a Data Table , you can put the "Sub Catgories names" as the key in the data table then have a second field which is the "Category" which it's linked to.

Then you have to create a data action for each category which will basically load the whole data table and then with Json path you only retrieve the Sub categories linked to the Category.

Then, you need to create an custom action in the Script invoked each time you select a category in the first Drop Down list and with condition you check wich data action to call to load the second drop down list.

I.E : if category == "Category 1" --> Call Data Action "Get Category 1" etc etc..

I hope this helps and if someone has a better idea I would be interested as well :slight_smile:

Kind regards,

Nathan.

1 Like

Hello @Nathan_Tossens

thanks for your response, will try this approach as well. I want to share also what I have tried and done it gives me the output that I want.
I create 4 duplicate pages on the script
1st page -> Main page with only Drop down "Category" is visible
then once I select a Category on the drop down I added a Change Action
with this custom actions

It will switch page depending on the value on the Category drop down
then on each pages the 2nd Drop down would be visible containing the values for sub-category for the selected category.
image
image
image

every time I changed the value for the "Category" drop down it will change page accordingly. although I run to an error when I did it multiple times like page suddenly hangs. so I will try your approach as yours is much good for future use also if categories expanded.

many thanks!

1 Like

Hi @Nathan_Tossens,

I was able to make it work using data action and list the results on the drop down thanks for sharing your idea!

Hi @Ernest_John_Nuque ,

happy I was able to help :slight_smile:

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.