How do I create search for multiple fields in dataset?

This part is the button-event, for example “onClick”, which calls a function (in your case it is the FILTERING-function) called “xxx”, or in this example it is called “ZZZ”

export function dropdown1_change(event) {ZZZ()}

And here one more time the function, which will be called by the button…

function ZZZ() { }

I’ve changed it myFilter - export function dropdown1_change(event) {myFilter()}
But now it comes up with the error - myFilter is not defined. I know this is a probably something simple :roll_eyes:

You have always to show your actual code, i can’t see your code and all the changes you have done.

I tought you would be able to do the rest of CODE

import wixData from"wix-data";

$w.onReady(function(){   }

export function dropdown1_change(event) {myFilter()}

function myFilter() {
    wixData.query("Therapies")  
      
    .contains('therapy', $w('#dropdown1').value)    
    .or(wixData.query("therapies")
    .contains('therapyType2', $w('#dropdown1').value))    
    .or(wixData.query("therapies")
    .contains('therapyType3', $w('#dropdown1').value))
    .find()
    .then( (results) => {
        console.log(results)
        $w('#repeater1').data = results.items;
    });
} 

This will probably be the ERROR throwing code-line…

wixData.query("therapies") 

Your Database-Name is surely NOT → “therapies” (perhaps → “Therapies”) ?

I did check the code, for me it works, if everything is setted up.
I checked it for just one filter-setting. Also the REPEATER do running.

Now it’s on you, to get this CODE running.

Good luck & happy coding.

Hey,
I would recommend this code, because the filter with

 $w('#repeater1').data = results.items

doesn’t work very good. At all if you use a loazy loader for better performance.

let lastFilterTitle;

function FilterSearch(title) {
  let filter = wixData.filter();

 if (lastFilterTitle !== title); {

 if (title) filter = filter.contains('field1', title).or(filter.contains("field2", title));

        lastFilterTitle = title;
    }
$w("#dataset1").setFilter(filter);
let debounceTimer;

function DebounceSearch_debounce(event) {
 if (debounceTimer) {
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
        FilterStecker($w("#input1").value, lastFilterTitle);
    }, 200);
}

if you need more fields, just add:

.or(filter.contains("fieldname", title))

on the first code.

Thanks for your help. I still can’t get it to work. I just don’t get it. Thanks anyway

Thanks, but that’s not working either :frowning:

Surely you just do something wrong.
Show your actual code and pics of all relevant elements of your project.

And let us find the PROBLEM.

That is all of my code. It was my first small attempt at using code on a search page.

This is the page - https://www.choicetherapies.co.uk/therapy-selection

No CODE was added here, can’t see any code.

On the page the code works, doesn’t it ?
And how it looks like you need a code for a dropdown, not for a search funktion, right ?

Yes looks like it works now. I am sure contact wanted to give us some new informations about his new code, because i am not sure if it is possible to do that without CODE (searching in 3 differents columns).

I am surely he/she has found a solution.

Hey, yes it’s working now thanks to the amazing help of russian-dima. I’m still looking at the code to figure it out. It looks so simple and elegant.

All I need to do now is link it back up with the map!

Please open a new post with a new topic, IF the problem is still uptodate.

https://www.wix.com/corvid/forum/community-discussion/hi-everyone-im-trying-to-link-google-maps-to-address-field-in-database-and-filter-by-a-type?origin=member_posts_page