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;
});
}
Please, someone can help me?Thanks
That code is for searching a database. You can return the results of the search to a repeater on your webpage so that the results can be viewed on screen.
Is that what you are trying to do ?
@mikemoynihan99 yes, I want to do something with te repeater.
With this code works but I also would to do the search by SKU for the products with the same search box. how can I do it?
import wixData from ‘wix-data’;
let debounceTimer;
export function input11_keyPress(event) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#input11’).value);
}, 200);
}
let lastFilterTitle;
function filter(title) {
if (lastFilterTitle !== title) {
$w(“#dataset1”).setFilter(wixData.filter().contains(‘name’,title));
lastFilterTitle = title;
}
}
@mikemoynihan99 Thank you so much!
And i I want to search it from another page?For example from the homepage?Is it possible?
@fraspace5
You said in one of your earlier posts that you wanted to return the results of the search to a repeater on your webpage. What page is your repeater located on ?
@mikemoynihan99 The repeater is located in a page but I would put the searchbox in another page,then be redirected to the repeater’s page.
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)
)
)
})
}
}
like this…
import wixData from ‘wix-data’;
export function input1_keyPress(event, $w) {
$w(“#dataset1”).onReady(() => {
let SearchValue = $w(“#input1”).value;
$w(“#dataset1”).setFilter(
wixData.filter()
.contains("name", SearchValue)
.or(
wixData.filter()
.contains("sku", SearchValue)
)
);
})
}
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
It’s easy to say, but difficult to do for me 
@fraspace5
details for wixLocation and wixStorage below:
@mikemoynihan99 How can I get the value from the input?
export function button37_click(event) {
session.setItem(“#input3”, “testo”);
wixLocation.to(“/ricerca-prodotti”);
}
@fraspace5
let SearchValue = $w(" #input1 ").value;
session.setItem(“SearchValue”, SearchValue);
@mikemoynihan99
import wixData from ‘wix-data’;
import { session } from ‘wix-storage’;
export function button35_click(event, $w) {
$w(“#dataset1”).onReady(() => {
let SearchValue = $w(“#input11”).value;
$w("#dataset1").setFilter(
wixData.filter()
.contains("name", SearchValue)
.or(
wixData.filter()
.contains("sku", SearchValue)
)
);
})
}
let value = session.getItem(SearchValue);
export function page1_viewportEnter(event) {
// 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 
what do you get when you console log on the repeater page ?
let value = session.getItem(‘SearchValue’);
console.log(value);