Adding search filter

I’m back - I utilised @code-queen code for adding a search to my site because it allows you to add a search bar on the home page and direct you to results with another search bar.

What I’m struggling to do is add a filter to further filter the search using a drop down.

I know wix have a search code tutorial, but wanted to know before starting again is it / would it be possible add code to my existing code? Or just start over?

The code I have is as follows:

 import { local } from 'wix-storage';
 import wixData from 'wix-data'; 
 
$w.onReady(function () {  var sameWord = local.getItem("searchWord"); 
$w('#searchBar').value = sameWord;
$w('#searchBar').placeholder = sameWord;   $w('#dynamicDataset').onReady(function () { search();
});
});

export function searchButton2_click() {search();}

  function search() {   wixData.query('LIVEJOBS')
.contains('jobTitle', $w('#searchBar').value)     .or(wixData.query('LIVEJOBS').contains('location', $w('#searchBar').value))     .or(wixData.query('LIVEJOBS').contains('skills', $w('#searchBar').value))     .find()
.then(res => {
$w('#repeater1').data = res.items; 
});

}

$w.onReady( () => {

  $w("#dynamicDataset").onReady( () => {
  $w("#repeater1").onItemReady( ($item, itemData, index) => {
  let theItem = itemData.role;
  var shortrole = theItem.substr(0,100);
  $item("#RoleText").text = shortrole + " . . . ";
  });
  }); 
 
 
 

Any advice much appreciated

Cheers
Tom

Tom, have you tried reaching out to @code-queen to see if she can help you out initially as you are using her code samples.

However, if you are looking at using a Wix tutorial to try another way, then I would suggest that you create them separately and not try to combine them both until you know that both are working fine by themselves.

2 Likes

Hello @thomas80559 … thanks for watching my early tutorial videos.

The tutorial you followed only has 1 search element. I have a tutorial site I have that shows one example of a multi search by using multiple elements that you can try.

As @givemeawhisky recommends, do no try to combine codes on your first try. Create them both separately to understand how they work and then try to combine them together.

The only wrong way to create a search function is when it doesn’t work. Since there are many ways of creating search functions there is no ‘right’ or ‘one way’ of developing them. Go with the one that makes most sense to you.

I hope this tutorial site works for you ( I apologize in advance, but there is no video for this site):
https://codequeen.wixsite.com/multi-search

If none of the above works for you, I offer private tutoring services to teach you step by step in creating whatever code functions you need. www.mycodequeen.com

Good luck on your project!

3 Likes

@givemeawhisky @code-queen thanks for this advice guys. I thought it was the case but wanted to double check prior to starting. @code-queen I followed your tutorial on the search and it works absolutely fine, so thanks for that too.

Apologies for not getting back sooner, I never got a notification, so only checked this morning.

1 Like