I’ve got the database search working for 1 field with it populating a table from my database (Members). I’m wondering if it is possible to use the same search box to search multiple fields. Example: If someone enters Betty in the search box it returns all files with the name Betty. Or if someone enters July in the search box it returns all files with a birthday in July. (I have field keys of name, address, birthday, phone)
An alternative would be to have a dropdown box with the different fields to search. Example: Someone would enter the name Betty in the text box and then select ‘name’ in the dropdown and then click search button and it returns all files with the first name Betty. Or someone would enter July in the text box and then select ‘birthday’ in the dropdown and click search button and it returns all files with a birthday in July.
Which sounds easier and how should I do this?
This is my current code.
import wixData from ‘wix-data’;
I’m not sure if I need to post a new question or continue with this topic (it is related).
I’ve got a table populated from a search. Now I would like for the user to be able to click the row and be directed to a dynamic item page based on the results of the search. Is this possible?
I have a table I am searching on. Here is the code I am using. Can you tell me how and where if i want to add a second table element to search on using the same search box? Currently my search box is searching on the title of a document. My documents have numbers and I would like to search on that as well using the same search box.
While the syntax for your code appears correct, at the moment it is not possible to execute multiple ORs within a query using this method.
Thank you for bringing it into our attention.
To make this work change your code as per the example below:
Please direct me for the code, (I want the table to disappear when there is no content in the input box, also if instead of dedicated search button, the ENTER key on the keyboard would work as the search button).
I want to put the result into a dynamic page, instead into the table. So after the customer put the item/id code the result will go into a dynamic page and show all the information of that particular item/id code.
Very interesting all this, but my database has MANY fields, is it possible to just say search everywhere instead of telling it EACH AND EVERY field to look into?
import wixData from ‘wix-data’;
export function searchinput1_onkeyPress() {
$w.onReady(function() {
wixData.query(“Inventaire”);
.contains( $w(‘’).value) //Obviously, this seems to be where the game will be played. It’s my ONLY red dot because I left the field blank
.find()
.then(res => {
$w(‘#table1’).rows = res.items;
Hmmmm. OK, so apparently I’ll have to list them all :-S
So just to make sure I got this right, for EACH field to search, if I have 30 fields (I have more than that, but just as an example), I’ll put 30 lines containing :
The script searches a database of companies, with names, addresses, city, states. 3. The script displays all the companies that match the search results in the following order. 1. Company Name Address City State