I tried doing this again by copying the code but making it different by doing two dropdowns instead of a user input and dropdown. The dropdown options appeared but when i clicked on one of them, they came up blank. Then when i pressed “All states” or “All Cities” it went back to normal
import wixData from ‘wix-data’ ;
$w.onReady( function () {
//TODO: write your page related code here…
loadbusinessType()
});
function loadbusinessType () { wixData.query( “Businesses1” ).limit( 1000 ).ascending( “businessType” ).distinct( “businessType” ).then((results) => {
let distinctList = results.items.map(element => { return {label: element, value: element};})
distinctList.unshift({ “value” : “” , “label” : “All Categories” })
$w( “#dropdown1” ).options = distinctList
})
}
let lastFilterName;
let lastFilterbusinessType;
function filter (name, businessType) {
if (lastFilterName !== name || lastFilterbusinessType !== businessType) {
let newFilter = wixData.filter();
if (name) { //this will check to see if there are any value for keywords
newFilter = newFilter.contains( “title” , name)
}
if (businessType) { //this will check to see if there are any value for continent
newFilter = newFilter.contains( “businessType” , businessType)
}
$w( “#dataset1” ).setFilter(newFilter);
lastFilterName = name;
lastFilterbusinessType = businessType;
}
}
let onTime;
export function input6_keyPress(event) {$w( “#loadingGif” ).show();
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
$w( "#dataset1" ).setFilter(wixData.filter().contains( "title" , $w( '#input6' ).value)
.or(wixData.filter().contains( "businessType" , $w( '#input6' ).value)
))
.then(() => {
count();
})
}, 200 );
//Add your code for this event here:
if (onTime) {
clearTimeout(onTime)
onTime = undefined;
}
onTime = setTimeout(() => {
filter($w( “#input6” ).value, lastFilterbusinessType)
}, 500 )
}
export function dropdown1_change(event) {
//Add your code for this event here:
filter(lastFilterName, $w( “#dropdown1” ).value);
}