Hello,
I have created a searchable database for a company website. On a separate page, a text input and a table element are used. Upon clicking the Search button, the custom code looks up the database entry and refreshes the table. The issue I am having is that, when a user enters nothing, the table will display all items on the database. Below is the custom code I am utilizing.
import wixData from "wix-data";
$w.onReady(function () {
filter('0');
});
function filter(certnumber) {
let newFilter = wixData.filter();
newFilter = newFilter.contains('certno', certnumber);
$w('#dataset1').setFilter(newFilter);
}
export function submitCert_click(event) {
filter($w('#certInput').value);
$w("#tableCert").refresh();
$w("#tableCert").expand();
}
How can I make it so that when nothing is typed inside the text input box, no results will be displayed.
Also, when I add an input that corresponds to the first digits of a database entry (the one checked by the code), the code displays all entries with matching first 3 digits.
Thank you in advance!