Trying to add second dropdown and checkbox filter

I have written my code to query a search based on a name, and then to further narrow the search I created a drop down for “state”. I want to create a second dropdown for “city” and then a checkbox filter to narrow the search even further (using tags from a db). Here is my code. Can someone help me figure out how to do this?

import wixData from "wix-data";

$w.onReady(() => {
    wixData.query('States')
        .find()
        .then(res => {
                let options = [{"value":  '', 'label': 'All States'}];
                options.push(...res.items.map(state => {
                    return {'value': state.title, 'label': state.title}
                }));
                $w('#iState').options = options;
    })
});
let lastFilterTitle;
let lastFilterState;

let debounceTimer;
export function iTitle_keyPress(event, $w) {
    if (debounceTimer) {
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
            filter($w('#iTitle').value, lastFilterState);
        }, 200);
    }

function filter(title, state) {
    if (lastFilterTitle  !== title || lastFilterState !== state) {
        let newFilter = wixData.filter();
        if (title)
            newFilter = newFilter.contains('breweryName', title);
        if (state)
            newFilter =  newFilter.eq('state', state);
        $w('#dataset4').setFilter(newFilter);
        lastFilterTitle = title;
        lastFilterState = state;
    }
}

export function iState_change(event, $w) {
    filter(lastFilterTitle, $w('#iState').value);
}

Read the following posts…

  1. Here we had a very intensive conversation about your topic…

Surely you will find even more about your wished functionality, if you use the search.

There are so many of them already to be found…

And even more…

One filter-example, which handles all scenarios ???

is possible ?

There was even an improved version of it ?

What do you think, are there even more examples out there?
So much stuff to read and to learn!!! :wink:

Should i continue ?

Ok, last one…

You have now found about 15% of examples! Could you already improve your coding-skills, regarding to create a FILTER-ENGINE ???

I appreciate the links but it looks like a lot of these are dealing with tables. I am using a repeater to search on results. There have been other posts with people helping solve the specific code they’re trying to deploy and that is what I’m looking for. If there are variables I’m missing and can get help filling those in, that would be greatly appreciated.