Tutorial: How to create a database searchbar 2
This tutorial aims to show you how to create a searchbar that is only on one page.
import wixData from 'wix-data';
$w.onReady(function () {
$w('#searchButton').onClick(function() {
search();
});
function search() {
wixData.query('Database').contains('field1', $w('#searchbar').value) .or(wixData.query('Database').contains('field2', $w('#searchbar').value)) .or(wixData.query('Database').contains('field3', $w('#searchbar').value))
.find()
.then(res => {
$w('#results').data = res.items;
});
}
});
/*change Database to the name of your database. Change field1, field2 & field3 to the fields you want to search */
//'#results' is a repeater.