Hey people,
I have a simple data base query to search a tracking number.
The tracking number is entered into input box and attached to a search button.
The results (only one) is loaded into a repeater.
The code is as
import wixData from "wix-data"; $w.onReady(function () { }); export function searchbutton_click(event) { wixData.query("Tracking") .contains("title", $w("#trackinginput").value) .find() // Run the query .then(res => { $w("#repeater1").data = res.items; $w("#repeater1").expand(); } ); }
No problems here.
However, I would like to show a container box [noresultsmessage] if there are no results.
I am not sure what code to use and would really appreciate any help.
Cheers
Stephen
Put a box or a tex somewhere in your form with a text like "No results found.". Make it hidden. Let's say it's called "boxNoResult". Your code would look something like:
export function searchbutton_click(event) { wixData.query("Tracking") .contains("title", $w("#trackinginput").value) .find() // Run the query .then(res => { if(res.items > 0){ $w("#repeater1").data = res.items; $w("#repeater1").expand(); } ); } } else { $w("#repeater1").hide(); $w('#boxResult').show(); }