Multiple dropdown filter

import wixData from 'wix-data';

 

//USE THIS LINE OF CODE FOR BUTTON ONCLICK

// export function searchButton_click_1(event) {

// search();

// }

 

$w.onReady(() => {

$w("#dropdown1, #dropdown2, #dropdown3").onChange(function () {

search();

});

});

 

function search() {

 

wixData.query("databaseID")

.contains("fieldkey1", String($w("#dropdown1").value))

.and(wixData.query("databaseID").contains("fieldkey2", String($w("#dropdown2").value)))

.and(wixData.query("databaseID").contains("fieldkey3", String($w("#dropdown3").value)))

//--------- COPY AND PASTE FROM THE .and() TO THE NEXT LINE TO ADD CODE FOR MORE DROPDOWN

 

.find()

.then(results => {

$w("#repeater1").data = results.items;

});

 

}

 

//Reset Filter

export function resetButton_click(event) {

 

$w("#dataset1").setFilter(wixData.filter())

 

$w("#dropdown1").value = undefined;

$w("#dropdown2").value = undefined;

$w("#dropdown3").value = undefined;

 

}