# dropdown menu filter ++

**URL:** <https://forum.wixstudio.com/t/dropdown-menu-filter/30356>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [February 9, 2018, 9:26am UTC](https://forum.wixstudio.com/t/dropdown-menu-filter/30356 "2018-02-09T09:26:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brandon-bornes](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/brandon-bornes/32/1953_2.png) [@brandon-bornes](https://forum.wixstudio.com/u/brandon-bornes)\
**Post date:** [February 9, 2018, 9:26am UTC](https://forum.wixstudio.com/t/dropdown-menu-filter/30356/1 "2018-02-09T09:26:45Z")

</div>

I made a database search with 2 dropdown filters. both filters only show what is in teh database to choose from. My first dropdown is city. my second dropdown is category.

I want to be able to choose a city on my first dowpdown menu, which would trigger the second drop down menu to only have options that are in that city

Here is code right now, but dont know what to do next. i dont know how to have the second dropdown filter base its results off of the first dropdown selection

import wixData from ‘wix-data’;

//For full API documentation, including code examples visit [http://wix.to/94BuAAs](http://wix.to/94BuAAs)

$w.onReady(function () {  
//TODO: import wixData from ‘wix-data’;  
});

export function button2\_click() {

wixData.query(‘Business’)  
.contains(‘industry’, $w(‘#dropdown2’).value)  
.contains(‘city’, $w(‘#dropdown1’).value)

```
.find() 

.then(res => { 
  $w('#repeater1').data = res.items; 
}) 
; 

```

}

$w.onReady(function () {  
wixData.query(“Business”)  
.ascending(‘industry’)  
.contains(‘city’, $w(‘#dropdown1’).value)  
.limit(1000)  
.find()  
.then(results =\> {

```
	  	const uniqueTitles = getUniqueTitles(results.items);    
	  	$w("#dropdown2").options = buildOptions(uniqueTitles);     
	}); 

function getUniqueTitles(items) {     
	// Use the map method to create the titlesOnly object containing all the titles from the query results 
		const titlesOnly = items.map(item => item.industry);    
	// Return an array with a list of unique titles 
   		return [...new Set(titlesOnly)]; 
} 
// Creates an array of objects in the form {label: "label", value: "value"} from the array of titles 
function buildOptions(uniqueList) {    
	return uniqueList.map(curr => { 
		// Use the map method to build the options list in the format {label:uniqueTitle, value:uniqueTitle} 
		return {label:curr, value:curr}; 
		
	}); 
} 

```

});

$w.onReady(function () {  
wixData.query(“Business”)  
.ascending(‘city’)  
.limit(1000)  
.find()  
.then(results =\> {

```
	  	const uniqueTitles = getUniqueTitles(results.items);    
	  	$w("#dropdown1").options = buildOptions(uniqueTitles);  
	  	
	  	
	}); 

function getUniqueTitles(items) {     
	// Use the map method to create the titlesOnly object containing all the titles from the query results 
		const titlesOnly = items.map(item => item.city);    
	// Return an array with a list of unique titles 
   		return [...new Set(titlesOnly)]; 
} 
// Creates an array of objects in the form {label: "label", value: "value"} from the array of titles 
function buildOptions(uniqueList) {    
	return uniqueList.map(curr => { 
		// Use the map method to build the options list in the format {label:uniqueTitle, value:uniqueTitle} 
		return {label:curr, value:curr};   
	}); 
} 

```

});

---

<div class="post-metadata">

**Author:** ![\_tal](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_tal/32/669_2.png) [@\_tal](https://forum.wixstudio.com/u/_tal)\
**Post date:** [February 11, 2018, 6:20am UTC](https://forum.wixstudio.com/t/dropdown-menu-filter/30356/2 "2018-02-11T06:20:34Z")

</div>

Hi Brandon,  
I recommend checking out the [Cascading Form](https://www.wix.com/code/home/example/Cascading-Form) example for the purpose.

Best,  
Tal.

---

<div class="post-metadata">

**Author:** ![mcschaap](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@mcschaap](https://forum.wixstudio.com/u/mcschaap)\
**Post date:** [February 12, 2018, 5:44pm UTC](https://forum.wixstudio.com/t/dropdown-menu-filter/30356/3 "2018-02-12T17:44:58Z")

</div>

Hi Brandon,

Did you get it solved? Can you post your code down below?

Thanks

---

<div class="post-metadata">

**Author:** ![marylin-montoya](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/marylin-montoya/32/669_2.png) [@marylin-montoya](https://forum.wixstudio.com/u/marylin-montoya)\
**Post date:** [May 22, 2018, 3:48pm UTC](https://forum.wixstudio.com/t/dropdown-menu-filter/30356/4 "2018-05-22T15:48:23Z")

</div>

Hello,

I am having a similar difficulty. I have a table connected to a database with three drop down filters to be added. I want the filters to be applied based on the selection of the other filters. I have no idea how to do this. Can ANYONE help? Please, it would be greatly appreciated!
