Show results from Dropdown

Hi Guys,

My website: www.swiss-medtech.ch/weiterbildung has a repeater that is connected to a dataset. I got one text field as well two dropdownfield which are working together just fine.

However I would also like to see the results when clicking on dropdown 1 (bereich) without having to choose from dropdown 2. I would like to have both options.

So i am guessing it needs only one little sentence which I cannot wrap my head around:

Here is the thing. AND THANKS IN ADVANCE:

import wixData from ‘wix-data’;

$w.onReady( function () {
uniqueDropDown1();
});

function uniqueDropDown1 (){
wixData.query(“Weiterbildung”)
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#dropdown1”).options = buildOptions(uniqueTitles);
});

function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.bereich);
return [… new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}

export function dropdown1_onChange(event) {
uniqueDropDown2();
}

function locationBereichFilter (){
$w(“#dataset1”).setFilter( wixData.filter()
.eq(“bereich”, $w(“#dropdown1”).value)
);
}

function uniqueDropDown2 (){
wixData.query(“Weiterbildung”)
.contains(“bereich”, $w(“#dropdown1”).value)
.limit(1000)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#dropdown2”).options = buildOptions(uniqueTitles);
});

function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.art);
return [… new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}
}

export function dropdown2_onChange(event) {
$w(“#dropdown2”).enable();
locationBereichFilter2();
}

function locationBereichFilter2 (){
$w(“#dataset1”).setFilter( wixData.filter()
.eq(“art”, $w(“#dropdown2”).value)
);
}

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

let lastFiltertitle;
function filter(title){
if (lastFiltertitle !== title){
$w(‘#dataset1’).setFilter(wixData.filter().contains(‘bezeichnung’, title));
$w(‘#dataset1’).setFilter(wixData.filter().contains(‘ort’, title));
$w(‘#dataset1’).setFilter(wixData.filter().contains(‘anbeiter’, title));
lastFiltertitle = title;
}
}

export function clearFIlters_onClick(event) {
$w(“#dataset1”).setFilter(wixData.filter(undefined));
$w(“#dropdown1”).value = 0;
$w(“#dropdown2”).value = 0;
}

Hello

it seems like you don’t call locationBereichFilter() function i assume that’s the issue.
try it out and if you still have the problem we can debug the code together :slight_smile:

Best
Massa

Dear Massa,

Thanks so much for your input!!! Unfortunately I have no idea what to do…

Lets say, I am a Newbie to Coding.

Many thanks,
Mario

Dear Massa,

I got it I got it I got it.

YOU ROOOOOOOCK - how can I repay my gratitude???

let me know

Hey Mario

I’m so glad to know that it worked !!
Thank youuuu