# Search in more then one column

**URL:** <https://forum.wixstudio.com/t/search-in-more-then-one-column/35040>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [November 17, 2017, 1:47am UTC](https://forum.wixstudio.com/t/search-in-more-then-one-column/35040 "2017-11-17T01:47:38Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![gotita-g](https://avatars.discourse-cdn.com/v4/letter/g/f14d63/32.png) [@gotita-g](https://forum.wixstudio.com/u/gotita-g)\
**Post date:** [February 20, 2018, 3:22am UTC](https://forum.wixstudio.com/t/search-in-more-then-one-column/35040/21 "2018-02-20T03:22:15Z")

</div>

Hi Yevhen,

So i tried everything you suggested except the repeaters (but I will - i just need to read more about it) and i want to say THANK YOU for all the great guidance! All of it works exactly as you say.

I will end up leaving the search box in the directory that links to the dedicated search page with the results already filteed and linked

You have no idea how happy all of this made me 🙂

If you want to see all your code working here are the links:

[https://gotitag.wixsite.com/travelmonth/copy-2-of-family-directory-search](https://gotitag.wixsite.com/travelmonth/copy-2-of-family-directory-search)

[https://gotitag.wixsite.com/travelmonth/FamiliesProfiles](https://gotitag.wixsite.com/travelmonth/FamiliesProfiles)

Again a million thanks. I honestly think you are the best at helping people in this forum, clear and always correct information!

Gotita

---

<div class="post-metadata">

**Author:** ![gotita-g](https://avatars.discourse-cdn.com/v4/letter/g/f14d63/32.png) [@gotita-g](https://forum.wixstudio.com/u/gotita-g)\
**Post date:** [February 20, 2018, 4:09am UTC](https://forum.wixstudio.com/t/search-in-more-then-one-column/35040/22 "2018-02-20T04:09:17Z")

</div>

I have one last request… 🙂 can you help me figure out how to return an message if the search word is not found in the datababse?

thank you!!!

---

<div class="post-metadata">

**Author:** ![yevhen-pavliuk](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yevhen-pavliuk/32/1053_2.png) [@yevhen-pavliuk](https://forum.wixstudio.com/u/yevhen-pavliuk)\
**Post date:** [February 20, 2018, 7:39am UTC](https://forum.wixstudio.com/t/search-in-more-then-one-column/35040/23 "2018-02-20T07:39:47Z")

</div>

Hi Gotita,

I am glad to be of help 🙂

---

<div class="post-metadata">

**Author:** ![yevhen-pavliuk](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yevhen-pavliuk/32/1053_2.png) [@yevhen-pavliuk](https://forum.wixstudio.com/u/yevhen-pavliuk)\
**Post date:** [February 20, 2018, 8:20am UTC](https://forum.wixstudio.com/t/search-in-more-then-one-column/35040/24 "2018-02-20T08:20:23Z")

</div>

Hi Gotita,

Regarding showing a message when there are no search results.

1. Add an element or group of elements that will be shown to the user if there are no search results. In my example, I added a simple text with the ID **noResultsMessage**. The element(s), as the results table, should be located right below the search box (i.e. they will overlap in Editor).
2. Make the element(s) hidden on load (in Properties panel).
3. Check out the following code example:

```javascript
import wixData from 'wix-data';
import wixLocation from 'wix-location';

$w.onReady(() => {
  $w('#dataset1').onReady(async () => {
    const { q = '' } = wixLocation.query;
    $w('#SearchBox').value = q;

    if (q !== '') {
      await search(q);
      await handleSearchResults();
    }
  });
});

export async function SearchBotton_onclick(event, $w) {
  const { value } = $w('#SearchBox');
  if (value !== '') {
    await search(value);
    await handleSearchResults();
  }
}

async function search(query) {
  await $w('#dataset1').setFilter(
    wixData
      .filter()
      .contains('location', query)
      .or(wixData.filter().contains('state', query))
      .or(wixData.filter().contains('city', query))
      .or(wixData.filter().contains('titleListing', query))
  );
}

async function handleSearchResults() {
  const resultsTable = $w('#resultsTable');
  const noResultsMessage = $w('#noResultsMessage');

  if ($w('#dataset1').getTotalCount() > 0) {
    await noResultsMessage.hide();
    await resultsTable.show();
  } else {
    await resultsTable.hide();
    await noResultsMessage.show();
  }
}

```

Regards,  
Yevhen

---

<div class="post-metadata">

**Author:** ![gotita-g](https://avatars.discourse-cdn.com/v4/letter/g/f14d63/32.png) [@gotita-g](https://forum.wixstudio.com/u/gotita-g)\
**Post date:** [February 20, 2018, 8:50pm UTC](https://forum.wixstudio.com/t/search-in-more-then-one-column/35040/25 "2018-02-20T20:50:23Z")

</div>

Hi again!

Thank you again! it works perfectly 🙂 So exciting!!!

Gotita

---

<div class="post-metadata">

**Author:** ![yevhen-pavliuk](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yevhen-pavliuk/32/1053_2.png) [@yevhen-pavliuk](https://forum.wixstudio.com/u/yevhen-pavliuk)\
**Post date:** [February 20, 2018, 8:54pm UTC](https://forum.wixstudio.com/t/search-in-more-then-one-column/35040/26 "2018-02-20T20:54:25Z")

</div>

Hi Gotita,

You are welcome! 🙂

---

<div class="post-metadata">

**Author:** ![andie0721](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/andie0721/32/15996_2.png) [@andie0721](https://forum.wixstudio.com/u/andie0721)\
**Post date:** [November 20, 2019, 9:59pm UTC](https://forum.wixstudio.com/t/search-in-more-then-one-column/35040/27 "2019-11-20T21:59:33Z")

</div>

Hello Yevhen, I have few questions and let me know if you are available.  
Thank you

---

<div class="post-metadata">

**Author:** ![yevhen-pavliuk](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yevhen-pavliuk/32/1053_2.png) [@yevhen-pavliuk](https://forum.wixstudio.com/u/yevhen-pavliuk)\
**Post date:** [November 21, 2019, 8:03am UTC](https://forum.wixstudio.com/t/search-in-more-then-one-column/35040/28 "2019-11-21T08:03:01Z")

</div>

Hello Cristina,

Go ahead, ask your questions. Me or someone else will respond you.

[Previous page](https://forum.wixstudio.com/t/search-in-more-then-one-column/35040.md?page=1)
