Making search bars work together

Hi there,

Im very new to code and have only started because I have been asked to make a new website for an estate agent, requiring a search bar for their database.

Having used Wix code to make their database, I have managed to create 3 separate search bars on my page. However… I need to be able to bring up results from at least 2 of the search bars, if not 3.

For example: I need to display results of the location search, as well as the property type search. I would need to display only the exact matches e.g Houses & London.

Below I have attached the 3 search bars and the code I have used to make them work independently.

Any help would be really appreciated!!!

Thanks
Tom

change the fieldIds to the filed Ids in your collection…

import wixData from “wix-data”;

export function searchButton_click(event) {
console.log($w(’ #searchInput ‘).value);
filter($w(’ #searchInput ').value);

function filter() {
$w(" #dataset1 “).onReady(() => {
$w(’ #dataset1 ').setFilter(
wixData.filter()
.contains(“fieldID1”, $w(” #searchInput “).value)
.or(
wixData.filter()
.contains(“fieldID2”, $w(” #searchInput “).value)
.or(
wixData.filter()
.contains(“fieldID3”, $w(” #searchInput ").value)
)
)
)
})
}
}

Hi Mike

Thanks so much for taking the time to get back. Much appreciated.

However when I added the new code, it allowed me to search all 3 topics through one search bar, but not to input something into all 3 search bars and be provided with a unique answer.

I.e. If you put london in the first search bar and click the button, it works. However if I then go to search bar 2 and enter data for ‘type’ of house e.g. flat then it doesn’t bring up flats in london.

Basically it seems to make the first search bar work for all 3 topics (location, type & address) but not allow all 3 to me used together.

Perhaps what i’m asking for is not possible! But again any further support would be hugely appreciated.

Kind regards
Tom

Ok it wasn’t clear what you were trying to do in your original post.

Solution here https://www.wix.com/code/home/forum/community-discussion/add-a-filter-to-dataset-but-also-keep-the-previous-filter