Hello everybody. I’m very new to programming but I am loving learning so much from everybody here.
I have an issue that I hope you Wix Superstars can assist with. I have built a database collection for my site and the form to submit data and everything works perfectly. Now, I would like my website visitors to be able to search that database using data that they input to two search boxes.
So, as per the attached screenshot, I have input1 and input2, with input1 being the business category and input2 being the city in which the business is. So, I would ideally like my visitors to type in that they are looking for a pharmacy(input1) in Cape Town(input2). The results are displayed on a repeater which has been connected to the data and the individual fields are pointing to the right fields in the database collection.
I have gotten as far as writing the code for the first input, but then I am stumped.
import wixData from ‘wix-data’;
$w.onReady( function () {
});
export function input1_keyPress(event) {
//Add your code for this event here:
let SearchValue = $w(“#input1”).value;
$w(“#dataset1”).setFilter(wixData.filter().contains(‘businessCategory’, SearchValue));
}
How do I code the second input to further filter the data. Currently what is happening if I type Pharmacy in input1, the repeater shows me all the pharmacies. However, when I type Cape Town into input2, the repeater then changes and shows me all the businesses in Cape Town, including pharmacies, butheries etc.
From my understanding and research within this forum and on YouTube, it has something to do with the .or/.and functions, but I cannot find any tutorial that can help me understand.
Can someone PLEASE PLEASE help me with the right code.
Thank you.