Hi, I’ve been using Wix for 4 years already
I want that when users write correctly words or the code then the table gave result. If I write in #searchBar2 “188” the table gives all results in words that have “188”
I want the table to give a result when writing a correct query (words or codes).
if I write a similar or incomplete query, then the table did not give a result.
there is my script, if you can fix it pls
//Search 1
import wixData from ‘wix-data’;
$w.onReady(function () {
//SEARCH BUTTON TRIGGER⚡
$w("#searchButton").onClick(function () {
search();
});
//ENTER KEY TRIGGER⚡
$w("#searchBar").onKeyPress(function (event) {
if (event.key === "Enter") {
search();
}
});
$w("#searchBar1").onKeyPress(function (event) {
if (event.key === "Enter") {
search();
}
});
$w("#searchBar2").onKeyPress(function (event) {
if (event.key === "Enter") {
search();
}
});
//SEARCH FUNCTION🚀
function search() {
$w("#dataset1").onReady(function () {
$w("#dataset1").setFilter(wixData.filter().contains('ad', String($w('#searchBar').value))
.and(wixData.filter().contains("marka", String($w('#searchBar1').value)))
.and(wixData.filter().contains("detalCode", String($w('#searchBar2').value)))
)
.then(count)
$w("#clearFilter").show();
})
}
//COUNT FUNCTION👍
function count() {
let count = $w("#dataset1").getTotalCount();
if (count > 0) {
$w("#countText").text = `${count} ehtiyat hissəsi tapıldı`;
} else { $w("#countText").text = `ehtiyat hissəsi tapılmadı`; }
return count;
}
//SCROLL TO THE TOP WHEN PAGINATION IS CHANGED ⚡
//CLEAR FILTER 🚀
$w("#clearFilter").onClick(function () {
$w("#searchBar1").value = undefined;
$w("#searchBar").value = undefined;
$w("#searchBar2").value = undefined;
//$w('#location').value = undefined;
$w("#clearFilter").hide();
$w("#dataset1").setFilter(wixData.filter()).then(count);
});
//COUNT BEFORE PAGE LOADS❗
$w("#dataset1").onReady(function () {
count();
});
});