Adding checkboxes to a "property search"

Dear all,
I got a property search working smoothly, with dropdowns, and connected to a database collection, that filter results and display it through a reapeater. Now i’d like to add “checkbox(es)” to get “more filter” like : “Swimming pool” and “balcony” and “garden”…
Here is the code i use for my dropdown search :
import {wixData} from ‘wix-data’;

export function button1_click(event, $w) {
$w(“#dataset1”).setFilter(wixData.filter()

    .contains("nomDuBien", $w('#dropdown5') .value) 
    .ge("pieces", $w('#dropdown2') .value) 
    .contains("jardin", $w('#radioGroup1').value) 
    .between("surface",parseFloat($w('#dropdown6').value), parseFloat($w('#dropdown7').value)) 
    .between("price",parseFloat($w('#dropdown3').value), parseFloat($w('#dropdown4').value))) 

.then((results) => { 

if ($w(“#dataset1”).getTotalCount() > 0) {
$w(“#repeater1”).expand();
$w(“#text80”).text = “Voici vos résultats”;
$w(“#repeater1”).data = results.items;
} else {
$w(“#repeater1”).collapse();
$w(“#text80”).text = “Désolé il n’y a pas de résultats, essayez d’autres critères”;
}
}). catch ((err) => {
console.log(err);
});

}
A basic… now, before results, i need to filter again with checkboxes checked or not. i already crated 3 more filter in my database collection : swimming pool / balcony / garden / that i set up on “boolean” with the check or not.
How should be my code after : .between(“price”,parseFloat($w(’ #dropdown3 ‘).value), parseFloat($w(’ #dropdown4 ').value))) to include my checkbox search ?? Thanks in advance to all of you.

Multi-Select Dropdown

Create a dropdown menu with checkboxes and search a database using multiple filters.

Thx Yisrael,
But the exemple you gave to me, is not the same thing i’m trying to do, i want to keep my dropdowns and ADD more checkboxes in 1 search. Maybe my title (Adding checkboxes to a “dropdown search”) isn’t right… so when i click on button, that runs the script that i have already, including my dropboxes, to get results. could you give me an example of code to add ?

export function button1_click(event, $w) { $w(" #dataset1 ").setFilter(wixData.filter()

.contains(“nomDuBien”, $w(’ #dropdown5 ‘) .value)
.ge(“pieces”, $w(’ #dropdown2 ‘) .value)
.contains(“jardin”, $w(’ #radioGroup1 ‘).value)
.between(“surface”,parseFloat($w(’ #dropdown6 ‘).value), parseFloat($w(’ #dropdown7 ‘).value)) .between(“price”,parseFloat($w(’ #dropdown3 ‘).value), parseFloat($w(’ #dropdown4 ').value)))
→ Here code for checkbox to include in the search…

Thx Yisrael,
But the exemple you gave to me, is not the same thing i’m trying to do, i want to keep my dropdowns and ADD more checkboxes in 1 search. Maybe my title (Adding checkboxes to a “dropdown search”) isn’t right… so when i click on button, that runs the script that i have already, including my dropboxes, to get results. could you give me an example of code to add ?
export function button1_click(event, $w) { $w(" #dataset1 ").setFilter(wixData.filter()
.contains(“nomDuBien”, $w(’ #dropdown5 ‘) .value)
.ge(“pieces”, $w(’ #dropdown2 ‘) .value)
.contains(“jardin”, $w(’ #radioGroup1 ‘).value)
.between(“surface”,parseFloat($w(’ #dropdown6 ‘).value), parseFloat($w(’ #dropdown7 ‘).value)) .between(“price”,parseFloat($w(’ #dropdown3 ‘).value), parseFloat($w(’ #dropdown4 ').value)))
→ Here code for checkbox to include in the search…

Oh - sorry I misunderstood. The thing is, that adding checkboxes is much like what you’re doing already. Just add filters based on the checkboxes as you are doing for the dropdowns and the radiogroup.

I don’t know what your database collection looks like, but you can use checkboxes as a filter on boolean fields in the collection.

@yisrael-wix Yes sir ! There’s some details i need to understand :
With my dropdowns i can use “.contains” or “.ge” “.between” but i don’t understand witch "fonction i have to use for my checkboxes (setted up with “boolean” in my collection.)
for example, I got a column “swimming pool” and some item are “checked” and some not.
How to translate this in code ?

@fizzfantasy You can get the value of a checkbox like this:

let isChecked = $w("#poolCheckbox").checked;

So to filter the [boolean] swimming pool column, you could add something like this to the filters:

.eq("swimmingPool", $w("#poolCheckbox").checked)

@yisrael-wix All right ! i’ll try this, and come will be back to you to… thanks !

@yisrael-wix
So i have created an action on my check box :

export function checkbox1_click(event) {
 let isChecked = $w("#checkbox1").checked; 
}

And included to my filter :

.eq("balcon", $w("#checkbox1").checked)          (Balcon = balcony)

When i click on my “search button” i got NO RESULTS… unless i click on my #checkbox1, to “check it”, so i got results with balcony only.
I would like to be able to search, even if the checkbox is not “checked”. In this case i got all results.
Thx !