How to add a search bar to my website that connected to my Database, for example, when I search the ID code of an Item, it will directly brings me to that item I search…
Hi! I think the most proper way is to use this
Create a text input field with some id (like #textInput1)
Create a button, for which you create a onClick event, add something like wixData.query(“name-of-collection).eq(“id”, $w(”#textInput1").value).find()
And then in promise print found value somewhere on stage
I think there is no way to achieve this without code… Only through dropdown, where all options are connected to specific ID field in collection. Then you chose one of them, which changes current item in dataset and shows other field on stage, which you searched
Hi Mkhail, Good Day :). Thank you for the tips. but I not a code geek. HAHAHAHA! unfortunately. I hope you can help me this more further.
Ok. so see this:
https://www.screencast.com/t/yECLktVUz
https://www.screencast.com/t/AKwzijuXF
this is a site with it all:
https://mikhails8.wixsite.com/mysite-318
this is the code:
import wixData from 'wix-data';
export function button1_click(event) {
wixData.query("data").eq("id", $w("#input1").value).find()
.then((result)=>{
$w("#text1").text = result.items[0].results;
});
}
Ask what you dont understand
Thank you Mikhail. you’re a savior!
Hi Mikhail, how can I route the result into a dynamic page? it is possible?
Hey Mikhail,
i am also interested in an anwer for Geo´s question because i am trying something similiar. I am also using a dynamic page and i am using the repeater strucutre from WIX to create a list.
The list is collapsed when the page opens. so i just wanna show results the person is looking for.
Is there anything different or special within the code block while i am using this on a repeater? If you know something about, i would appreciate your help too, Geo.
Also i am stuck with two errors and i am lousy when it comes to the WIX syntax. Which parameter i am supposed to choose after “button2_click”( ? )
And it says that “text is unused” after i inserted #repeater1.
Thanks in advance!
import wixData from ‘wix-data’;
export function button2_click( event ) {
wixData.query(“data”).eq(“Title”,“category”,“city”, $w(“#input1”).value).find()
.then((result)=>{
$w(" **#repeater1** ").text = result.items[0].results;
});
}
what is the text1 field in the code?