How to Search a simple Database and Display as table?

Hi, I have created a simple Student DB and now I want to search by Student Name. I watched a video in youtube and coded it by adding javascript and onclick functio. but it stopped working now suddenly. can someone post the code here?

This is the code snippet. I have added the function name as onclick function for the button. It worked for few days and now it’s not. I verified the field names and DB entries and they are correct but still not getting any data back. Please help

please upload a screenshot of your collection’s contents, and its permission settings.
thanks.

1 Like

Thanks for the response Ziv. Appreciate it.
The field key is studentName and I tried by giving the permission to Site members and Anyone but still no luck. I am sharing the collection structure. I hope you can help me to make it work.

i have the same contents in Live Database. Im searching for the name RIYAZ which is DB but there is no result. I configured the field name as studentName fr the table and all the other fields and added the correct function name as onClick even for the Button. I dont see any spelling mistakes or syntax errors. Even if you can suggest different working code snippet then it should be fine for me. Waiting for your response :slight_smile:

Could you please share your site address.
Could you tell whether the query to the database returns no errors or maybe the click event not fired?

1 Like

Hi Shay. I don’t get any error but looks like the click event isn’t getting fired even though the function name is correct. Below is my site address

Please help me out as I am completely struck and needs to complete it in 2 days

Hi, can someone please help me out with this issue? I don’t understand what is wrong with my code and why a simple search isn’t working. I have to complete it by tomorrow and I am getting frustrated with this :cry:

Hi, I was trying different things and noticed that the onclick event is getting fired but the contains () function isn’t working which is to search based on name. I verified the field key and it is correct. When I removed the contains statement it is returning all the rows in the database. What am I doing wrong here?

Hi wix team, sorry but I am really getting frustrated now as I am not getting any resolution for a simple query and you guys are talking about introducing complex stuffs. I tried everything to solve this issue including restoring to the old version for which my search query was working but even it didn’t work. Initially I was happy that I got to know about wix but I think it’s time to look elsewhere. Can someone in Wix help me out before I actually say goodbye :cry:

Hi,

search seems to work in Preview. You probably haven’t synced the data to Live.

You need to go to Content Manager and click Sync → Copy All Items To Live.

Let me know how it went.

Thanks for the response. I do have some data in the live database and I am searching for the same. I have already tried by syncing up the data as well but it never worked.
As I mentioned in my previous comments it doesn’t fetch due to contains() method and if I remove it I get back all the entries.

Hi Riyaz,

I checked your live site and everything seems to be working correctly - button click handler does fire and the table displays expected results. Can you please share your environment details, like operating system, browser name and version?
Also, if you could post a screenshot with browser console open after you click the button, that might also help us in finding the cause of the issue.

Oh God. you are correct. I downloaded Chrome in my laptop and it worked. I was using IE and it did work the first time and also it was working when I removed contains().
Not sure what’s wrong. Thanks a lot. I am super excited now. Appreciate your help :blush:

I had another question. I am searching by the first name but without providing the name and just by clicking Search button it is returning all the data in the table.
How do we add not blank or null check in the code I shared above? I want the data to be fetched only when the user enters the name

Never mind. I figured this out myself by adding a simple if condition by checking the input value is not blank.
I also wanted to display an alert statement but usual alert() isn’t supported in wix. Is there any alternative to show the user a message?