Searching a Database with a Less Than or Equal To

Hi all,

I’m new to coding, but have got some bits together and i’m currently building a search page to find records. I have a dropdown option that works great, but I want 2 fields that allow a minimum and Maximum search on a number. I’ve tried many things, but as soon as I add the code for min and max, it fails. Can anybody tell me what i’m missing?

function SearchCaravan() {
wixData.query(“Caravan”)
.contains(“site”, $w(“#LUSite”).value)
.eq(“active”, true )
.eq(“approved”, true )
.eq(“forSale”, true )
.ge(“caravanBerth”, $w(“#MinBerth”).value)
.le(“caravanBerth”, $w(“#MaxBerth”).value)

.find() // Run the query
.then(res => {
$w(“#CaravanSale”).data = res.items;
});
}

You can do this without using code if you wanted to.
https://support.wix.com/en/article/filtering-content-based-on-user-selection

To do it with code, have a look at previous forum posts.
https://www.wix.com/corvid/forum/community-discussion/add-multiple-custom-filter-on-dynamic-page

You can also look at using a Slider instead of a dropdown option too.
https://www.wix.com/corvid/reference/$w.Slider.html

Brilliant! Thanks for this. I’ve used the slider in the end to get this working.
I started off using the non-coded version, but found that I was never able to have an ALL option if the dropdown boxes are not selected.