Hello guys, I tried to make a search box for my site but I doesn't understand how to do it.
I found this code around the forum but it says that .text doesn't exist on #results1, thanks.
import wixData from 'wix-data';
export function productbutton_click(event) {
wixData.query("Products").eq("Title","Sku", $w("#input11").value).find()
.then((result)=>{
$w("#results1").text = result.items[0].results;
});
}
@Fraspace5
It seems like in your "results" page, in the 'ViewportEnter' function you defined the filter but did not deploy it on your Dataset.
Also, in your home page there's a use of an invalid selector.
Fix those and see if its working and let me know.
Doron.
Is anyone willing to help me, please?
Link to my original post:
https://www.wix.com/code/home/forum/community-discussion/help-with-database-search-code
Somebody can help us?
Hi there, I'm really struggling with creating a database search box on my site... Would one of you be willing to help me?
what do you get when you console log on the repeater page ?
let value = session.getItem('SearchValue');
console.log(value);
Homepage Code:
export function button37_click(event) { let SearchValue = $w('#input3').value; session.setItem(SearchValue, SearchValue); wixLocation.to('/ricerca-prodotti'); }
Repeater page code:
export function page1_viewportEnter(event) { $w("#dataset1").onReady(() => { let value = session.getItem('SearchValue'); wixData.filter() .contains("name", 'SearchValue') .or( wixData.filter() .contains("sku", 'SearchValue') ); }) }
Doesn't work very well :)
Yes it is possible to search it from another page.
You would pass the "SearchValue" to wixStorage.
Then use wixLocation to redirect the user to the page with the repeater on it
On the page with the repeater get the "SearchValue" from wixStorage.
Then just run the above code to filter the dataset
I also have a problem with this code, look:
import wixData from 'wix-data'; export function input11_keypress(event) { filter($w('#input11').value); function filter(title,sku) { $w("#dataset1").onReady(() => { $w('#dataset1').setFilter( wixData.filter() .contains("name", $w("#input11").value) .or( wixData.filter() .contains("sku", $w("#input11").value) ) ) }) } }
Please, someone can help me?Thanks