Hi everyone!
This has been giving me a mayor headache so hopefully you can help me! I have a database table set up on my page and to search that database I’ve added a searchbar and a dropdown menu. Neither update the results on the table. I’ll add screenshots and the code at the bottom of this.
I’ve tried several different codes (all found on youtube, I’m not a dev) .
All help is highly appreciated.
Bonus: If someone could also tell me if I can add sort filters to each column? Ascending/Descending.
The table is #table1 , the search bar is #searchInput and the drop down menu is #dropdown1 all connected to #dataset2
import wixData from 'wix-data';
$w.onReady(function () {
$w('#searchInput').onInput(() => {
search();
})
});
function search() {
wixData.query("Items1")
.contains("title", $w('#searchInput').value)
.or(wixData.query("Items1").contains("title", $w('#searchInput').value))
.find()
.then(results => {
$w('#table1').data = results.items;
});
}
$w.onReady(function () {
$w('#dropdown1').onChange(() => {
search1();
})
});
function search1()
wixData.query("Items1")
.contains("title", $w('#dropdown1').value)
.or(wixData.query("Items1").contains("agentName", $w('#dropdown1').value))
.find()
.then(results => {
$w('#table1').data = results.items;
});
}