You do not have to change anything within the FILTER-ENGINE-FUNCTION.
Do not touch the CODE itself. Just modify the “User-Interface-Values”.
Wrong-way…
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('#dropdown'+DDprefix+(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
})
}
Right way…
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('#'+DDprefix+(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
})
}
Ok, one more time all CODE-PARTS together…
import wixData from 'wix-data';
//------------[VARIABLES]---------------------|
var DropDowns= [] //-----> do not touch or change this :-) !
var MEMdropdowns = [] //-----> do not touch or change this :-) !
//------------[VARIABLES]---------------------|
//------------[User-Interface-----------------------------------------------------|
var DATABASE = "Dupree_stuff" //-----> here the NAME of your DATABASE (NOT DATASET!)!
var databaseLIMIT = 1000 //-----> here the LIMIT of your SEARCH-RESULTS in DB!
var REPEATER = "repeater2" //-----> here the ID of your used REPEATER! (without #)
var DDprefix = "dropdown" //rename related dropdowns, like shown DDprefix -> dropdown)
//----------------------------------
DropDowns[0] = "site" ; //column in your DATABASE
DropDowns[1] = "location" ; //column in your DATABASE
DropDowns[2] = "advisor" ; //column in your DATABASE
DropDowns[3] = "undefined" ; //column in your DATABASE
DropDowns[4] = "undefined" ; //column in your DATABASE
DropDowns[5] = "undefined" ; //column in your DATABASE
DropDowns[6] = "undefined" ; //column in your DATABASE
DropDowns[7] = "undefined" ; //column in your DATABASE
DropDowns[8] = "undefined" ; //column in your DATABASE
DropDowns[9] = "undefined" ; //column in your DATABASE
//------------[User-Interface-----------------------------------------------------|
//------------starting CODE-part when page loads.....
$w.onReady(function () {
load_uniqueTitles_DropDowns();
//-----> SITE-DropDown-------
$w('#sitedropdown').onChange(()=>{console.log("Site-DropDown clicked")
MEMdropdowns[0] = $w('#sitedropdown').value
$w('#sitedropdown').enable();
FILTER_ENGINE()
})
//-----> LOCATION-DropDown-------
$w('#locationdropdown').onChange(()=>{console.log("Location-DropDown clicked")
MEMdropdowns[1] = $w('#locationdropdown').value
$w('#locationdropdown').enable();
FILTER_ENGINE()
})
//-----> ADVISOR-DropDown-------
$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.....
//----->DO NOT TOUCH OR CHANGE THIS FUNCTION.
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]!=="undefined" && DropDowns[a]!==null) {
await dbDATA.distinct(DropDowns[a])
.then((results) => {
let items = results.items
console.log(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]
})
}
}
}
//----->DO NOT TOUCH OR CHANGE THIS FUNCTION.
function FILTER_ENGINE(){
let query = wixData.query(DATABASE).limit(databaseLIMIT)
//Filter-DropDowns-------------------------------------------
for (let i=0; i < DropDowns.length; i++) {
if (MEMdropdowns[i]!==undefined && MEMdropdowns[i]!=="undefined"){
$w('#'+DDprefix+(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 //---> # <---- already include here
})
}
Just Copy&Paste this code to your page and rename your DropDown-Prefixes—> to —> “dropdown” and hope, that i did not forget something or wrote an syntax-error ![]()
Check also the CONSOLE !
Good luck and happy coding!![]()