Multiple Filters for dropdown input

Hi guys!

I’m a little stuck and need some help. I’m trying to create a form that will allow a users to select a specific “slot” 3 times and then it will be filtered out from the dataset.

I currently have it working but it seems i cant have multiple filters called at the same time as it will only use one.

Here is what I currently have:

Two databases, one that’s for the submissions and the other for the dropdown list.
The rest of the code is below.


$w.onReady( function () {
//Call the function getData after something was submitted to the dataset
$w(‘#dataset1’).onAfterSave(getData);

});

function getData () {

//Get the submitted value from the drop down, compare that value and add 1 to the stored value.

let dateValue = $w(‘#dropdown1’).value
console.log(“Input value to database”, dateValue);

//Code for Sat 2 PM - 4 PM EST
if (dateValue === “Sat 2 PM - 4 PM EST”) {
satTwoFour = Number(satTwoFour) + 1;
local.setItem(“storedSatTwoFour”, satTwoFour);
console.log(“Sat 2 PM - 4 PM EST value increase”, satTwoFour);

if (satTwoFour >= 3) {
deleteSatTwoFour = Boolean( true );
hideDropdownRows();
}

}

//Code for Sat 12 PM - 2 PM EST
if (dateValue === “Sat 12 PM - 2 PM EST”) {
satTwelveTwo = Number(satTwelveTwo) + 1;
local.setItem(“storedSatTwelveTwo”, satTwelveTwo);
console.log(“Sat 12 PM - 2 PM EST value increase”, satTwelveTwo);

if (satTwelveTwo >= 3) {
deleteSatTwelveTwo = Boolean( true );
hideDropdownRows();
}

}

//Code for Sat 10 AM - 12 PM EST
if (dateValue === “Sat 10 AM - 12 PM EST”) {
satTenTwelve = Number(satTenTwelve) + 1;
local.setItem(“storedSatTenTwelve”, satTenTwelve);
console.log(“Sat 10 AM - 12 PM EST value increase”, satTenTwelve);

if (satTenTwelve >= 3) {
deleteSatTenTwelve = Boolean( true );
hideDropdownRows();
}

}

//Code for Sat 8 AM - 10 AM EST
if (dateValue === “Sat 8 AM - 10 AM EST”) {
satEightTen = Number(satEightTen) + 1;
local.setItem(“storedSatEightTen”, satEightTen);
console.log(“Sat 8 AM - 10 AM EST value increase”, satEightTen);

if (satEightTen >= 3 ) {
deleteSatEightTen = Boolean( true );
hideDropdownRows();
}

}
}

// This function gets called once a value is >= 3
function hideDropdownRows () {

var array_BoolTriggers = [deleteSatEightTen, deleteSatTenTwelve, deleteSatTwelveTwo, deleteSatTwoFour]
console.log(“array Data”, array_BoolTriggers);

switch ( true ) {
case array_BoolTriggers[0]:
console.log(“Switch Sat Eight to Ten”);
$w(‘#dataset2’).setFilter(wixData.filter()
.ne(“title”, “Sat 8 AM - 10 AM EST”)
)
break ;
case array_BoolTriggers[1]:
console.log(“Switch Sat Ten to Twelve”);
$w(‘#dataset2’).setFilter(wixData.filter()
.ne(“title”, “Sat 10 AM - 12 PM EST”)
)
break ;
case array_BoolTriggers[2]:
console.log(“Switch Sat Twelve to Two”);
$w(‘#dataset2’).setFilter(wixData.filter()
.ne(“title”, “Sat 12 PM - 2 PM EST”)
)
break ;
case array_BoolTriggers[3]:
console.log(“Switch Sat Two to Four”);
$w(‘#dataset2’).setFilter(wixData.filter()
.ne(“title”, “Sat 2 PM - 4 PM EST”)
)
break ;

}


The issue seems to be if I try and have multiple cases called at the same time, only one will be filtered. I need if both 12 - 2 and 2 - 4 values are true ( selected more then 3 times) to both be removed fromt he dropdown. If I have it setup like this:

$w(’ #dataset2 ').setFilter(wixData.filter()
.ne(“title”, “Sat 12 PM - 2 PM EST”)
.ne(“title”, “Sat 2 PM - 4 PM EST”)
)

It will filter out both 12 - 2 and 2-4 from the drop down, since they are both being called at the same time on .setFilter

Maybe there is a way I can have a “gate” for the .setFilter and list all four values and which ever are true will allow the code to be run.

Something like this?

$w(’ #dataset2 ').setFilter(wixData.filter()
.ne(“title”, “Sat 8 AM - 10 AM EST”)
.ne(“title”, “Sat 10 AM - 12 PM EST”)
.ne(“title”, “Sat 12 PM - 2 PM EST”)
.ne(“title”, “Sat 2 PM - 4 PM EST”)
)