# Search function for a repeater

**URL:** <https://forum.wixstudio.com/t/search-function-for-a-repeater/5254>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [September 21, 2018, 8:43pm UTC](https://forum.wixstudio.com/t/search-function-for-a-repeater/5254 "2018-09-21T20:43:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![karelhonys23](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/karelhonys23/32/6302_2.png) [@karelhonys23](https://forum.wixstudio.com/u/karelhonys23)\
**Post date:** [September 21, 2018, 8:43pm UTC](https://forum.wixstudio.com/t/search-function-for-a-repeater/5254/1 "2018-09-21T20:43:55Z")

</div>

Hi all,  
I’m using a repeater connected to my database. I have a search bar and I am using code from the video on “how to create a search for your database”. But when I go in preview and try to search for something nothing will show up and when I click out of the search bar borders of the search bar get red.

**1.** How could I code to make the search bar look for values in columns **Title** and **Description** in database?

**2.** Furthermore, In case there would be many findings how could I set that only 30 results will be shown per page please?

I am currently using code that is below, but it is not functional:

import wixData **from** “wix-data”

**let** debounceTimer;  
export function iTitle\_keyPress(event, $w) {  
**if** (debounceTimer) {  
clearTimeout(debounceTimer);  
debounceTimer = undefined;  
}  
debounceTimer = setTimeout(() =\> {  
filter($w(‘#iTitle’).value);  
}, 200);  
}

**let** lastFilterTitle;  
**function** filter(title) {  
**if** (lastFilterTitle !== title) {  
$w(‘#dataset1’).setFilter(wixData.filter().contains(‘Title’, title));  
lastFilterTitle = title;  
}  
}

Looking forward to your tricks and tips! Thank you!  
Karel

---

<div class="post-metadata">

**Author:** ![\_tal](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/_tal/32/669_2.png) [@\_tal](https://forum.wixstudio.com/u/_tal)\
**Post date:** [September 25, 2018, 6:44am UTC](https://forum.wixstudio.com/t/search-function-for-a-repeater/5254/2 "2018-09-25T06:44:37Z")

</div>

Hi Karel,  
I would start with following the example I wrote [here](https://www.wix.com/code/home/forum/community-discussion/equal-to-or-more-than) for filtering a repeater. If you have any further questions about the example, let me know 🙂

Best,  
Tal.

---

<div class="post-metadata">

**Author:** ![karelhonys23](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/karelhonys23/32/6302_2.png) [@karelhonys23](https://forum.wixstudio.com/u/karelhonys23)\
**Post date:** [September 25, 2018, 10:01pm UTC](https://forum.wixstudio.com/t/search-function-for-a-repeater/5254/3 "2018-09-25T22:01:45Z")

</div>

Thank you so much! I am going to go through it! Thanks a lot!

Best,  
Karel

---

<div class="post-metadata">

**Author:** ![karelhonys23](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/karelhonys23/32/6302_2.png) [@karelhonys23](https://forum.wixstudio.com/u/karelhonys23)\
**Post date:** [September 26, 2018, 9:45pm UTC](https://forum.wixstudio.com/t/search-function-for-a-repeater/5254/4 "2018-09-26T21:45:11Z")

</div>

Hi Tal,

I tried to code today, but it does not work yet. I used something from the code you referred to and something from the video I mentioned above. You can see my **code below**.

Right now if I type something into the Search bar everything disappears and when I click out of the Search bar the borders get red. **Wix tells me this** : " _Wix code SDK Warning: The src parameter of “image4” that is passed to the src method cannot be set to null or undefined._ "

**My attributes:**  
Repeater = #repeater1  
Search bar = #iTitle  
Picture = #image4  
Text = #text19  
Dataset = #dataset1

Still, I would like to have a Search bar that would get me 30 results per page. What do you think I could do next, please? If you had any time to help I would appreciate it! Thank you in advance!

**My code:**  
**import** wixData **from** ‘wix-data’;

**let** originalPropertiesInfo = ;  
$w.onReady( **function** () {  
//Query to get the information from the database  
wixData.query(“Properties”)  
.find()  
.then((results) =\> {  
originalPropertiesInfo = results.items;  
$w(`#repeater1`).data = originalPropertiesInfo;  
})  
. **catch** ((err) =\> {  
**let** errorMsg = err;  
});  
//Set the information to the repeater  
$w(‘#repeater1’).onItemReady(($w, itemData) =\> {  
//add here all the relevant elements of the repeater //In this case, I’ve added a text and an image to the repeater  
$w(‘#text19’).text = itemData.title;  
$w(‘#image4’).src = itemData.images;  
});  
});

**let** debounceTimer;  
export function iTitle\_keyPress(event, $w) {  
$w(‘#repeater1’).data = lastFilterTitle;  
**if** (debounceTimer) {  
clearTimeout(debounceTimer);  
debounceTimer = undefined;  
}  
debounceTimer = setTimeout(() =\> {  
filter($w(‘#iTitle’).value);  
}, 200);  
}

**let** lastFilterTitle;  
**function** filter(title) {  
**if** (lastFilterTitle !== title) {  
$w(‘#dataset1’).setFilter(wixData.filter().contains(‘Title’, title));  
lastFilterTitle = title;  
}  
}

Best regards,  
Karel
