How to Create a SharePoint Online List With Cascading Drop Downs
Cascading drop downs are drop downs (choice fields) whose behavior depends on the selections made in another drop down. A good example would be the selection of a state resulting in a second drop down then only showing the cities and towns in that particular state. Sadly, this is not a built-in feature of SharePoint. But there is a simple way to do this by following the steps below.
You’ll need to create three lists:
- The list with the top level selection (for example, states).
- Another list with the second level selection (for example, city/state).
- The list on which the cascades will actually be used.
Remember that when you implement this solution, you can simply replace “State” in these instructions with your top level, and “City” with your second level.
First, create a list called “State”. You won’t need any additional fields. Simply add all 50 states (50 rows of data) into the Title field.
Next create a list called “City”. In this list, the Title field will be used to hold the city values, but you’ll also add an additional field – a lookup field. Get information from the State list, and from the “Title” column only. (“In this column”.)
You’ll have to not only add all all your cities in the Title field of this list, but you’ll also have to select their corresponding State from the State lookup field you just created. This is what will create the connection between the two values.
Third, you’ll create your most important list – the list you needed in the first place! In this list, in addition to any fields you need, you’ll also have to add two lookup tables: one just as above for the City list, and one for State, from the State list.
Now, we do two steps on this list:
- From Advanced list settings, we set the view of this list to Classic SharePoint. The code we need to use won’t work on Modern pages – only classic view.
- Then we will have to edit the New Form page, and the Edit page.
You can get to these pages in several ways, but the easiest is from the Form Web Parts drop down in the List settings tab:
You’ll need to add a Content Editor web part to the Default New Form, and Default Edit Form (so the cascades also work if you’re editing an already-existing list item).
Edit the HTML markup of the Content Editor web part, and add the code.
Here’s where you will need to make some edits to your code. But don’t fret – it’s easy! Remember, this is where you’ll be replacing City and State with the field names that apply to your environment and the lists you’ve just created.
Once you add this code to the Content Editor web part, you can stop editing the page, and give it a go! Now, once you select your state, your city choices will be limited to cities in the selected state!