Filtering Repeater Values Using Multiple Dropdowns and Input Boxes

Hi everyone,

I’m trying to make a modified version of the tutorial shown here:
https://www.wix.com/corvid/forum/wix-tips-and-updates/how-to-create-a-search-for-your-database

Instead of having one search box and one drop down box, i would like to have 2-3 drop down boxes. But am unsure how to modify my code because the 2nd and 3rd drop down boxes do not filter the way the first one does. I think my problem is to do with the function filter(title, category, region) statement and using the multiple OR statements.

The website page is here:
https://ashfromashburton.wixsite.com/content/mid-canterbury-region

The hike name and hike type filters work correctly as per the You Tube video but when I try change the Region filter, then it doesn’t filter anything and just turns the screen white.

I want to only show the results that match all of the four filters. But I don’t need cascading filters so that the selection in one affects the other; the filters will always show all of the possible options.

The code is below:

import wixData from “wix-data” ;

$w.onReady(() => {
loadContinents();
loadRegions();
});

let lastFilterTitle;
let lastFilterContinent;
let lastFilterRegion;

let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w( ‘#iTitle’ ).value, lastFilterContinent, lastFilterRegion);
}, 200 );
// Add your code for this event here:
}

function filter(title, category, region) {
if (lastFilterTitle !== title || lastFilterContinent !== category || lastFilterRegion !== region) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains(‘title’,title);
if (category)
newFilter = newFilter.eq(‘category’,category);
if (region)
newFilter = newFilter.eq(‘region’,region);
$w(‘#dataset1’).setFilter(newFilter);
lastFilterTitle = title;
lastFilterContinent = category;
lastFilterRegion = region;
}
}

function loadRegions() {
wixData.query( ‘Items’ )
.distinct( “region” )
.then(res => {
let distinctListr = buildOptions(res.items);
distinctListr.unshift({ “value” : ‘’ , “label” : ‘All Continents’ });
$w( ‘#iRegion’ ).options = distinctListr;
});
}

function loadContinents() {
wixData.query( ‘Items’ )
.distinct( “category” )
.then(results => {
let distinctList = buildOptions(results.items);
distinctList.unshift({ “value” : ‘’ , “label” : ‘All Continents’ });
$w( ‘#iType’ ).options = distinctList;
});
}

function buildOptions(items) {
return items.map(curr => {
// Use the map method to build the options list in the format {label:uniqueTitle, value:uniqueTitle}
return { label: curr, value: curr };
});
}

export function iRegion_change(event, $w) {
filter (lastFilterRegion, $w( ‘#iRegion’ ).value);
// Add your code for this event here:
}

export function iType_change(event, $w) {
filter (lastFilterTitle, $w( ‘#iType’ ).value);

// Add your code for this event here:
}

Hey,
you want one searchbar and 2-3 dropdowns. The filter should show all results, that have the value of the searchbar and of all dropdowns ??

Can you send a picture of your database and your Filter design please ?
Do you only use text fields in your database or, do you use boolean fields, too ?

Hi Nick, thanks for your prompt reply.

Yes I’ve got one searchbar and 3 dropdowns. The filter should show all results that match the searchbar and all the dropdowns like you said.

I’ve only got text fields in the database.


The field keys for the three columns are “category”, “difficulty” and “region” respectively. There’s one dataset in my page “#dataset1”. This refers to a content collection named "Hike List"with the collection ID “Items”.

The filter items are as set up like below. There’s iType, iDifficulty and iRegion.

I’ve gotten the text search and one of the dropdowns to work but as soon as I add the second dropdown it stops working.

@the_gumby_next_door Wouldn’t it be nice to search “Very Hard” and “Easy” at the same time ? So that user can klick multiple checkboxes in the Dropdown ?

The filter would show you all results, that have the search bar value, one of dropdown one (Very Hard, Easy) ?

There is a way to build your own dropdown menue, to check multiple boxes in the dropdown.

Would this better ?

Please send me your code you use.

Hi Nick,

Yes it would be nice! I looked into making my own drop down menu by using a mini repeater but it looked quite complicated so decided against it.

I’ve also realised that instead of coding the drop down lists I can simply filter my dataset by the dropdown values. I can hard code the drop downs and now I’ve got all three dropdowns working in tandem which is great.

My code has become a lot simpler as a result but the only thing I’m having trouble with now is getting my dropdown filters to work with my text input box.

Anything written in text input box overwrites any filters put in the drop down.

The page is here:
https://ashfromashburton.wixsite.com/content/mid-canterbury-region

The code is here:
import wixData from “wix-data” ;

let lastFilterTitle;

let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w( ‘#iTitle’ ).value,$w( ‘#iType’ ).value,$w( ‘#iDifficulty’ ).value,$w( ‘#iRegion’ ).value);
}, 200 );
// Add your code for this event here:
}

function filter(title) {
if (lastFilterTitle !== title) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains( ‘title’ ,title);
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterTitle = title;
}
}

// Add your code for this event here:

export function iType_change(event) {
// Add your code for this event here:
if ($w( ‘#iType’ ).value === ‘All’ ) {
$w( ‘#iType’ ).placeholder = ‘All’ ;
$w( ‘#iType’ ).value = null ;
$w( ‘#iType’ ).resetValidityIndication();
}
else {}
}

export function iDifficulty_click(event) {
// Add your code for this event here:
if ($w( ‘#iDifficulty’ ).value === ‘All’ ) {
$w( ‘#iDifficulty’ ).placeholder = ‘All’ ;
$w( ‘#iDifficulty’ ).value = null ;
$w( ‘#iDifficulty’ ).resetValidityIndication();
}
else {}
}

export function iRegion_click(event) {
// Add your code for this event here:

if ($w( ‘#iRegion’ ).value === ‘All’ ) {
$w( ‘#iRegion’ ).placeholder = ‘All’ ;
$w( ‘#iRegion’ ).value = null ;
$w( ‘#iRegion’ ).resetValidityIndication();
}
else {}
}

I would do it a bit different. Why don’t you create indivudual dropdowns with a little bit of code ? Looks much nicer and you can search for Easy and Hard walking tracks at the same time.

Create 2 Container Boxes
1.

  1. Make sure the checkbox in properties is checked

Create a onClick funktion for the first dropdown. Add this code:

export function boxStecker_click(event) {
 if ($w('#boxDropDown').collapsed === true) {
        $w("#boxDropDown").expand();
    } else {
        $w("#boxDropDown").collapse();
    }
}

Then add single checkboxes (not multiple checkboxes).


export function SearchButton_click() {
    Filter();
    Suchleiste_debounce();
}

let lastFilterTitle;

function Filter(title) {
 let filter = wixData.filter();
 
 let Difficulty = $w("#checkboxEasy").checked || $w("#checkboxHard").checked //add all checkboxes here
 
 //add Region and Hike Type the same way
 let Region = .... || .... || .... || ...;

 if (Difficulty) {
        filter = filter
            .contains("Easy", $w("#checkboxEasy").checked)
            .or(
                filter
                .contains("Hard", $w("#checkboxHard").checked)
            ); // add all results here (Easy, Moderate, Hard, Very             
                Hard)
    }
// add Region and Hike Type the same way
 if (Region) {
        filter = filter


 if (lastFilterTitle !== title) {

 if (title) {
            filter = filter
                .contains('DatabaseFieldKeyToSearch', title)
                .or(
                    filter
                    .contains("addHereAnotherFieldKeyIfYouNeed", title)
                )
                );
        }

        lastFilterTitle = title;
    }

    $w('#dataset1').setFilter(filter)
}

let debounceTimer;

function Suchleiste_debounce(event) {
 if (debounceTimer) {
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
        Filter($w("#nameOfSearchbar").value, lastFilterTitle);
    }, 200);
}

Hi Nick,

Thanks for your help.

I’ve set up the two container boxes (#boxStecker and #boxDropDown) as per your instructions and have four single checkboxes as part of #boxDropDown. For each checkbox I’ve selected “Enabled by default” in the properties and in settings it is not set to “Checked by default”. Meaning they appear as unchecked boxes the user can check.

I’ve got an onClick event for #boxStecker and also amended your code to put an onKeyPress event to the search box (#iTitle).

The database keys I would like to search are “title” for the searchbox and “difficulty” for the checkboxes.

I’ve had no luck getting the checkboxes to work however. Clicking on the #boxStecker container box hides and drops down the menu as expected but checking the checkboxes on and off do not run a filter of any sort.

The search box itself works correctly.

Code is below:

$w.onReady( function () {
// TODO: write your page related code here…
$w( “#vectorImage1” ).target = “_self” ;
$w( “#image5” ).target = “_self” ;
});

import wixData from “wix-data” ;

export function SearchButton_click() {
Filter();
Suchleiste_debounce();
}

let lastFilterTitle;

function Filter(title) {
let filter = wixData.filter();
let Difficulty = $w( “#checkboxEasy” ).checked || $w( “#checkboxModerate” ).checked || $w( “#checkboxHard” ).checked || $w( “#checkboxVhard” ).checked

if (Difficulty) {
filter = filter.contains( ‘Easy’ , $w( “#checkboxEasy” ).checked)
.or(filter.contains( ‘Moderate’ , $w( “#checkboxModerate” ).checked))
.or(filter.contains( ‘Hard’ , $w( “#checkboxHard” ).checked))
.or(filter.contains( ‘Very Hard’ , $w( “#checkboxVhard” ).checked));
}
if (lastFilterTitle !== title) {

if (title) {
filter = filter
.contains( ‘title’ , title)
.or(
filter
.contains( ‘difficulty’ , title))
;
}

    lastFilterTitle = title; 
} 

$w( '#dataset1' ).setFilter(filter) 

}

let debounceTimer;

function Suchleiste_debounce(event) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
Filter($w( “#iTitle” ).value, lastFilterTitle);
}, 200 );
}

export function boxStecker_click(event) {
if ($w( ‘#boxDropDown’ ).collapsed === true ) {
$w( “#boxDropDown” ).expand();
} else {
$w( “#boxDropDown” ).collapse();
}
}
// Add your code for this event here:

export function iTitle_keyPress(event) {
Suchleiste_debounce()
// Add your code for this event here:
}

I can see no search button on the picture, do you have one ?

exportfunction SearchButton_click() {    Filter();    Suchleiste_debounce();}

This triggers your function. You can set a onClick event for every single checkbox, but everytime you check/uncheck a checkbox the filter runs. For me a button would be more comfortable, but not necessary.

Another problem from the filter is, that I build it for boolean fields, sorry about that.

So you have 2 options to change that:

  1. You create some boolean fields in your database and check them, if they are true


One for easy, one for very hard, …

If you use boolean fields, change .contains to .eq

filter = filter.contains('Easy', $w("#checkboxEasy").checked)

‘Easy’ is wrong here, you need they field key. for example in this picture the field key is “easy”

Then you should use this code style:

filter = filter
.contains('Easy', $w("#checkboxEasy").checked)                  
.or(
filter
.contains('Moderate', $w("#checkboxModerate").checked)
)
.or(
...

I don’t know why this style is better, but a very good developer in this forum told me it is.

Do you want to make a dropdown for Category and Region, too ?
When yes, I have to rewrite the code, but I’m in a hurry today, I have to write some codes for my website.

If you use the boolean fields, please send me your code again, no matter if it works or not.
You have some small mistakes in there, but which are not so relevant.

Hi Nick,

I’d prefer not to use boolean fields in my dataset because otherwise my table will have to get really wide to accommodate columns for all the combinations for the three dropdown boxes.

I’m not in a rush though so if you wouldn’t mind sending through a modified version of the code which deals with only text fields and applies the filters then I’ll try get it working.

You might be interested in using Selection Tags . Refer to the Selection Tags API for more information.

Hey, do you still need help ?

Hi Nick,

I think I’ve made some good progress. I’ve been working with just standard drop-downs to make things a bit simpler on the coding front. I’ve gotten the drop-downs and the text input to work well together except that I can only activate the filter function using the text input.

I don’t know how to call the filter function by putting a onKeyPress event for each of the drop-downs. At the moment if you search something in the input and then change the drop-downs, it runs the filter() function and just shows the full list. If you can help me get the onKeyPress event working to have the same code run as when a user presses a key in the input that would be a big help!

The website page is here:

The code is here:
$w.onReady( function () {
// TODO: write your page related code here…
$w( “#vectorImage1” ).target = “_self” ;
$w( “#image5” ).target = “_self” ;
$w( “#iType” ).show();
$w( “#iDifficulty” ).show();
$w( “#iRegion” ).show();
});

import wixData from “wix-data” ;

let lastFilterTitle
let lastFilterRegion
let lastFilterCategory
let lastFilterDifficulty

let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w( ‘#iTitle’ ).value, lastFilterTitle);
}, 200 );
// Add your code for this event here:
}

function filter(title,region,category,difficulty) {
if (lastFilterTitle !== title || lastFilterRegion !== region || lastFilterDifficulty !== difficulty || lastFilterCategory !== category) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter
.contains( ‘title’ ,title)
.and(
newFilter
.contains( ‘region’ ,$w( ‘#iRegion’ ).value))
.and(
newFilter
.contains( ‘category’ ,$w( ‘#iType’ ).value))
.and(
newFilter
.contains( ‘difficulty’ ,$w( ‘#iDifficulty’ ).value)
)
.and(newFilter
.eq( ‘completed’ , 1 ))
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterTitle = title;
if (category)
newFilter = newFilter
.contains( ‘title’ ,title)
.and(
newFilter
.contains( ‘region’ ,$w( ‘#iRegion’ ).value))
.and(
newFilter
.contains( ‘category’ ,$w( ‘#iType’ ).value))
.and(
newFilter
.contains( ‘difficulty’ ,$w( ‘#iDifficulty’ ).value)
)
.and(newFilter
.eq( ‘completed’ , 1 ))
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterCategory = category;
if (region)
newFilter = newFilter
.contains( ‘title’ ,title)
.and(
newFilter
.contains( ‘region’ ,$w( ‘#iRegion’ ).value))
.and(
newFilter
.contains( ‘category’ ,$w( ‘#iType’ ).value))
.and(
newFilter
.contains( ‘difficulty’ ,$w( ‘#iDifficulty’ ).value)
)
.and(newFilter
.eq( ‘completed’ , 1 ))
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterRegion = region;

if (difficulty)
newFilter = newFilter
.contains( ‘title’ ,title)
.and(
newFilter
.contains( ‘region’ ,$w( ‘#iRegion’ ).value))
.and(
newFilter
.contains( ‘category’ ,$w( ‘#iType’ ).value))
.and(
newFilter
.contains( ‘difficulty’ ,$w( ‘#iDifficulty’ ).value)
)
.and(newFilter
.eq( ‘completed’ , 1 ))
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterDifficulty = difficulty;
}
}

export function iType_change(event) {
// Add your code for this event here:
if ($w( ‘#iType’ ).value === ‘All’ ) {
$w( ‘#iType’ ).placeholder = ‘All’ ;
$w( ‘#iType’ ).value = null ;
}
else {
iTitle_keyPress
filter()
// $w(‘#dataset1’).setFilter()
}
}

export function iDifficulty_change(event) {
// Add your code for this event here:
if ($w( ‘#iDifficulty’ ).value === ‘All’ ) {
$w( ‘#iDifficulty’ ).placeholder = ‘All’ ;
$w( ‘#iDifficulty’ ).value = null ;
$w( ‘#iDifficulty’ ).resetValidityIndication();
}
else {
iTitle_keyPress
filter()
// lastFilterTitle = null;
/// debounceTimer = null;
// $w(‘#dataset1’).setFilter()
}
}

export function iRegion_change(event) {
// Add your code for this event here:

if ($w( ‘#iRegion’ ).value === ‘All’ ) {
$w( ‘#iRegion’ ).placeholder = ‘All’ ;
$w( ‘#iRegion’ ).value = null ;
$w( ‘#iRegion’ ).resetValidityIndication();
}
else {
iTitle_keyPress
filter()
/// $w(‘#iTitle’).value = “”
// lastFilterTitle = null;
// debounceTimer = null;
// $w(‘#dataset1’).setFilter()
}
}

Why do you want to make a onKeyPress event for a dropdown ? onKeyPress means, that it should run a function, if you press a key. You have to set the dropdowns onChange (as you have already done).

You have a big error on your debounce function and much more in your code.

But at first, what’s this ?

$w.onReady(function () {
$w("#vectorImage1").target = "_self";
$w("#image5").target = "_self";
w("#iType").show();
$w("#iDifficulty").show();    $w("#iRegion").show();
 });

What does this code and why do you have to show the dropdowns ?


Before you start to change your code, duplicate your page!

You have to split this function from:

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

into:

let debounceTimer;
export function iTitle_keyPress(event, $w) {
debounce();
filter();
}


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

Then change the code of all your dropdowns to:

exportfunction iDifficulty_change(event) {
if ($w('#iDifficulty').value === 'All') {    $w('#iDifficulty').placeholder = 'All';    
$w('#iDifficulty').value = null;    $w('#iDifficulty').resetValidityIndication();
}else {      
debounce(); 
filter();
}}

You shouldn’t set a new filter here.

After you changed that for ALL dropdowns, bring all you little dropdown functions above “function filter” and function debounce".


Let’s go ahead to your function filter.
You have to set your if clauses in this brackets {}

Means, you have to change “if (title), if (category), if (region), if (difficulty)”.

And delete " $w(‘#dataset1’).setFilter(newFilter);" from all if clauses, you have to place it at the end of the hole function (I’ll show you later)

if (region) {           
newFilter = newFilter            
.contains('title',title)            
.and(                
newFilter                
.contains('region',$w('#iRegion').value))            
.and(                
newFilter                
.contains('category',$w('#iType').value))            
.and(                
newFilter                .contains('difficulty',$w('#iDifficulty').value))            
.and(newFilter                
.eq('completed',1))            

lastFilterRegion = region;   
}

At the end of the “function filter” you shoud use this code:

if (difficulty) {            
newFilter = newFilter            
.contains('title',title)            
.and(                
newFilter                
.contains('region',$w('#iRegion').value))            
.and(                
newFilter                
.contains('category',$w('#iType').value))            
.and(                
newFilter                .contains('difficulty',$w('#iDifficulty').value))            
.and(
newFilter                
.eq('completed',1))        

       
lastFilterDifficulty = difficulty;       
} 
$w('#dataset1').setFilter(newFilter); 
  }
}

$w(‘#dataset1’).setFilter(newFilter); has to be outside of this functions

"if (title), if (category), if (region), if (difficulty)"

and inside this function:

if (lastFilterTitle !== title || lastFilterRegion !== region || lastFilterDifficulty !== difficulty || lastFilterCategory !== category) {

And what is this ?

.and(newFilter.eq('completed',1))

I hope I haven’t forgot something.

Hi Nick,

Thanks for your help and time. I’ve finally got it working!

I had some trouble getting your code to work with regard to the multiple or function ( lastFilterTitle !== title || lastFilterRegion !== region || lastFilterDifficulty !== difficulty || lastFilterCategory !== category) and also separating the debounce function.

In the end I went with an alternate approach and set up a separate filter function for each dropdown. And just got rid of all the boolean operators. Using your code I could only get the filters to work using the title boolean. It would never process the code through region/difficulty/category for reasons I couldn’t work out.

Thanks again for your time and effort, I definitely wouldn’t have gotten there without the lessons in this thread from you about how the different segments of the code work!

Website is : https://ashfromashburton.wixsite.com/content/track-list

Code for curiosity is below:

import wixData from “wix-data” ;

let lastFilterTitle
let lastFilterRegion
let lastFilterCategory
let lastFilterDifficulty

let debounceTimer;

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

export function iType_change(event) {
// Add your code for this event here:
if ($w( ‘#iType’ ).value === ‘All’ ) {
$w( ‘#iType’ ).placeholder = ‘All’ ;
$w( ‘#iType’ ).value = null ;
filter2()
}
else {
filter2($w( ‘#iType’ ).value);
// $w(‘#dataset1’).setFilter()
}
}

export function iDifficulty_change(event) {
// Add your code for this event here:
if ($w( ‘#iDifficulty’ ).value === ‘All’ ) {
$w( ‘#iDifficulty’ ).placeholder = ‘All’ ;
$w( ‘#iDifficulty’ ).value = null ;
$w( ‘#iDifficulty’ ).resetValidityIndication();
filter4()
}
else {
filter4($w( ‘#iDifficulty’ ).value);
// lastFilterTitle = null;
/// debounceTimer = null;
// $w(‘#dataset1’).setFilter()
}
}

export function iRegion_change(event) {
// Add your code for this event here:

if ($w( ‘#iRegion’ ).value === ‘All’ ) {
$w( ‘#iRegion’ ).placeholder = ‘All’ ;
$w( ‘#iRegion’ ).value = null ;
$w( ‘#iRegion’ ).resetValidityIndication();
filter3()
}
else {
filter3($w( ‘#iRegion’ ).value);
// $w(‘#iTitle’).value = “”
// lastFilterTitle = null;
// debounceTimer = null;
// $w(‘#dataset1’).setFilter()
}
}

function filter(title) {
let newFilter = wixData.filter();
newFilter = newFilter
.contains( ‘title’ ,title)
.and(
newFilter
.contains( ‘region’ ,$w( ‘#iRegion’ ).value))
.and(
newFilter
.contains( ‘category’ ,$w( ‘#iType’ ).value))
.and(
newFilter
.contains( ‘difficulty’ ,$w( ‘#iDifficulty’ ).value)
)
.and(newFilter
.eq( ‘completed’ , 1 ))
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterTitle = title;
}

function filter2(category) {
let newFilter = wixData.filter();
newFilter = newFilter
.contains( ‘title’ ,$w( ‘#iTitle’ ).value)
.and(
newFilter
.contains( ‘region’ ,$w( ‘#iRegion’ ).value))
.and(
newFilter
.contains( ‘category’ ,$w( ‘#iType’ ).value))
.and(
newFilter
.contains( ‘difficulty’ ,$w( ‘#iDifficulty’ ).value)
)
.and(newFilter
.eq( ‘completed’ , 1 ))
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterCategory = category;
}

function filter3(region) {
let newFilter = wixData.filter();
newFilter = newFilter
.contains( ‘title’ ,$w( ‘#iTitle’ ).value)
.and(
newFilter
.contains( ‘region’ ,$w( ‘#iRegion’ ).value))
.and(
newFilter
.contains( ‘category’ ,$w( ‘#iType’ ).value))
.and(
newFilter
.contains( ‘difficulty’ ,$w( ‘#iDifficulty’ ).value)
)
.and(newFilter
.eq( ‘completed’ , 1 ))
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterRegion = region;
}

function filter4(difficulty) {
let newFilter = wixData.filter();
newFilter = newFilter
.contains( ‘title’ ,$w( ‘#iTitle’ ).value)
.and(
newFilter
.contains( ‘region’ ,$w( ‘#iRegion’ ).value))
.and(
newFilter
.contains( ‘category’ ,$w( ‘#iType’ ).value))
.and(
newFilter
.contains( ‘difficulty’ ,$w( ‘#iDifficulty’ ).value)
)
.and(newFilter
.eq( ‘completed’ , 1 ))
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterDifficulty = difficulty;
}

function debounce(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w( ‘#iTitle’ ).value, lastFilterTitle);
}, 200 );
}

This is exactly what I am trying to do. I looked at your code, but am having issues making it my own. I’m new to this type of code… what is the placeholder name of the search field? also, is this the “final” code above?
thanks!

I am trying to do what you are doing and tried your code but it didn’t work. Was the code you listed here your final version?