My issue: Right now I can search with the “contains” field for Location, breed, Sex, Rabbitry names, and all together, but I can’t figure out how to
make the “Any” options work, so you don’t have to refresh the page in order to change the dropdown searches to include all results; and
How to make it so that you can search “male” without it also including “female” and “American” without it including American Chinchilla, American Fuzzy Lop, etc etc. I tried “eq” instead of “contains”, but it made it so none of the other filters would work anymore.
let sexValue;
if ($w("#sexDropdown").value !== "all") {sexValue = $w("#sexDropdown").value;}
//and in the filter itself use sexValue instead of $w("#sexDropdown").value
@jonatandor35 When I try to do .eq, it works, but only for THAT menu. It doesn’t allow any other menu to filter items. Just comes up with no items displayed.
@jonatandor35 I don’t know why it doesn’t work, but I’ve tried it with every field and it doesn’t work. It’s as though if I select .eq(“breed”… and then select “American”, it populates JUST American (like I want) but then if I try to search for both American AND Indiana (which is valid search) it cannot find it.
@showrabbitsales in my response above, I have 2 blocks of code.
the first one should be right after $w.onReady(function() {
The second one, should be right after the $w(“#searchButton”).onClick(() => {
I have to check out for a bit, but I will check back later for your help. I really do appreciate it, and I apologize for not understanding, if I’m missing something!
@showrabbitsales I don’t know why you’re using startWith here and not .eq().
but let’s try something else:
inside the onClick()
let filter = wixData.filter();
let sexValue;
if ($w("#sexDropdown").value === "all") {sexValue = false;}
else {sexValue = $w("#sexDropdown").value;}
if(sexValue){
filter = filter.startWith("sex", sexValue);
}
if(location){
filter = filter.eq("location", $w("#stateDropdown").value);
}
//add if's to all the parameters then:
$w("#dataset1").setFilter(filter);
//and the rest of the code
and needless to say you need to import wixData at the beginning of your code (that’s obvious).
Also, you should keep in mind that this filtering is case-sensitive, so filtering for “male” won’t filter-in “Male” etc…