Hi,
When my pages opens up, I have 6 different dropdowns which are populated based on the unique elements in a collection for the respective filter. I would like to save that full list of values, however I am somehow not able to do.
Here is the code:
$w.onReady(() => {
createDropdown(“category”, “#categoryLocation”);
createDropdown(“typeOfLocation”, “#typeOfService”);
createDropdown(“price”, “#priceRangeDropdown”);
createDropdown(“capacity”, “#capacityDropdown”);
createDropdown(“rating”, “#ratingSelection”);
createDropdown(“region”, “#allRegions”);
createDropdown(“place”, “#allPlaces”);
});
unction createDropdown(category, dropDownName) {
wixData.query(“Wedding_Database”)
.limit(10)
.ascending(category)
.distinct(category)
.then(results => {
let distinctList = buildOptions(results.items);
// Add “Alle” to the existing list
distinctList.unshift({ “value”: ‘’, “label”: ‘Alle’ });
// build the unique elemnt list
$w(dropDownName).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.toString(), value: curr.toString() };
});
}
I tried a number of different things, among others, but nothing gives me the results I am looking for.
//let myFullListCategories = dropdownOptions[0].value;
//let myFullListCategories = $w(“#categoryLocation”).options.value;
Thanks a lot for your help!