Filter dynamic page content through 2 dropdowns

Hi @Ahmad ,
thank you very much for your help. The code was useful and helped. In the end, I solved the problem with the help of your code and code from “Code Queen”.

Thanks again for the help and your time
Check https://www.sokoltouskov. cz/soupiska/a-tym/2020-2021

It’s just interesting that filling and assigning the current dropdown value takes about 1 second after the page loads. Visitors can flash the values in dropdowns.

Now I have set the “wixLocation. to” command to be executed whenever the value in the dropdowns changes. I don’t use the push button. And now I have come to an anomaly. The “wixLocation. to” command is executed before the corresponding “season-year” value is filled into the dropdown. This causes the visitor to be redirected to a page that may not exist. The dropdown command is preceded by a page redirection command.

export function dropdownTeam_change(event) {
wixData.query(“Sezona”)
.contains(“tym”, $w(“#dropdownTeam”).value)
.limit(100)
.find()
.then(results => {
const uniqueTitles = getUniqueTitles(results.items);
$w(“#dropdownSeason”).options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.sezona);
return […new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr => {
return {label:curr, value:curr};
});
}

const AktualniTym = $w(‘#dropdownTeam’).value
const AktualniSezona = $w(‘#dropdownSeason’).value
wixLocation.to(/soupiska/${AktualniTym}/${AktualniSezona});
}