I am building a website for a real estate company. The requested search features are as follows : Listing Type, Property Type, Price Range (from-to) and Location (town,county,state, zip code).
I first created a search bar where the user can type in the location they’re interested in. That works perfectly.
I then created several dropdowns - Listing Type, Property Type and Price (from) and Price (to). I added a button to search when one or more Dropdowns are selected. I can’t seem to get the dropdowns to search and filter. I’ve checked the code and my fieldTypes and everything seems to be right. What in the world am I doing wrong?
Also, I’d like to add a Reset button so the dropdowns can all be reset and all listings reappear in the Repeater. If anyone can help me with that code as well, I’d be over the moon.
Thank you!!
This is my code:
import wixData from ‘wix-data’;
$w.onReady( function () {
//TODO: write your page related code here…
});
export function input1_keyPress(event, $w) {
let searchValue = $w(“#input1”).value;
$w(“#dataset1”).setFilter(wixData.filter().contains(‘town’,searchValue)
.or(wixData.filter().contains(‘newField’,searchValue))
.or(wixData.filter().contains(‘state’,searchValue))
.or(wixData.filter().contains(‘county’,searchValue)));
}
$w.onReady( function () {
});
export function button2_click(event, $w) {
//Add your code for this event here:
$w(“#dataset1”).setFilter(wixData.filter()
.contains(“listingType”, $w(‘#dropdown3’).value)
.contains(“propertyType”, $w(‘#dropdown4’).value)
.between(“price”,parseFloat($w(‘#dropdown1’).value), parseFloat($w(‘#dropdown2’).value)))
.then((results) => {
console.log(“Dataset is now filtered”);
$w(“#repeater1”).data = results.items;
}). catch ((err) => {
console.log(err);
});
$w(“#repeater1”).expand();
}
Screenshot of page and database: