var DDprefix = "#sitedropdown, #locationdropdown, #advisordropdown";
No, DDprefix is the prefix-ID of all your dropdowns…
EXAMPLE: If you have for example 3x dropdowns called “DD1”, “DD2”, “DD3”, than your DDprefix would be —> “DD”.
If your 3x dropdowns would have the following IDs → “dropdown1”, “dropdown2”, “dropdown3”, than the DDprefix would be —> dropdown.
In simple words → prefix + index (dropdown-index) = dropdown-ID.
You will have to rename your dropdowns to one prefix ---->
dd1, dd2, dd3 or dropdown1, dropdown2, dropdown3, all IDs should have the same PREFIX
Or to generate an ARRAY ---->
myDropdowns = ["#sitedropdown, #locationdropdown, #advisordropdown"]
No! No dataset. This example uses DATABASE (COLLECTION), no DATASET!
var DATABASE = "#newbuilddataset"
RIGHT!
var DATABASE = "Collection-Name" ----> "Dupree_stuff"
OK!
var REPEATER = "#repeater2"
var DropDowns= []
var MEMdropdowns = []
OK!
DropDowns[0] = "site" ;
DropDowns[1] = "location" ;
DropDowns[2] = "advisor" ;
-----------------------------------CODE-UPDATE-II-------------------------------------------
import wixData from 'wix-data';
//------------[User-Interface-----------------------------------------------------|
var DATABASE = "Dupree_stuff"
var REPEATER = "#repeater2"
var DDprefix = "dropdown" //rename related dropdowns, like shown DDprefix -> dropdown)
//----------------------------------|
DropDowns[0] = "site" ; //column in your DATABASE ("title")
DropDowns[1] = "location" ; //column in your DATABASE
DropDowns[2] = "advisor" ; //column in your DATABASE
//------------[User-Interface-----------------------------------------------------|
var DropDowns= []
var MEMdropdowns = []
//------------starting CODE-part when page loads.....
$w.onReady(function () {
load_uniqueTitles_DropDowns();
$w('#sitedropdown').onChange(()=>{console.log("Site-DropDown clicked")
MEMdropdowns[0] = $w('#sitedropdown').value
$w('#sitedropdown').enable();
FILTER_ENGINE()
})
$w('#locationdropdown').onChange(()=>{console.log("Location-DropDown clicked")
MEMdropdowns[1] = $w('#locationdropdown').value
$w('#locationdropdown').enable();
FILTER_ENGINE()
})
$w('#advisordropdown').onChange(()=>{console.log("Advisor-DropDown clicked")
MEMdropdowns[2] = $w('#advisordropdown').value
$w('#advisordropdown').enable();
FILTER_ENGINE()
})
});
//-----loading of DropDown-Unique-Titles for all given DropDowns.....
async function load_uniqueTitles_DropDowns() {
console.log("Load uniqueTitles for DropDowns")
let dbDATA = await wixData.query(DATABASE)
let Options = []
for (var a = 0; a < DropDowns.length; a++) {
if(DropDowns[a]!==undefined && DropDowns[a]!=="site" && DropDowns[a]!==null) {
await dbDATA.distinct(DropDowns[a])
.then((results) => {
let items = results.items
for (var b = 0; b <items.length; b++) {
Options.push([])
Options[a].push({"label": items[b], "value": items[b]})
}
$w('#'+DDprefix+(a+1)).options = Options[a]
$w('#'+DDprefix+(a+1)).placeholder = DropDowns[a]
})
}
}
}
function FILTER_ENGINE(){
let query = wixData.query(DATABASE).limit(1000)
//Filter-DropDowns-------------------------------------------
for (let i=0; i < DropDowns.length; i++) {
if (MEMdropdowns[i]!==undefined && MEMdropdowns[i]!=="undefined"){
$w('#'+DDpräfix+(i+1)).value = MEMdropdowns[i]
query = query.eq(DropDowns[i], MEMdropdowns[i])
}
}
query.find()
.then(async res => {
let itemData = await res.items
console.log(itemData)
$w('#'+REPEATER).data = itemData
})
}
Here your example…
And here your DB-PRESET (main)…
https://www.media-junkie.com/pflegeservice

