# Empty results for front-end filtering

**URL:** <https://community.weweb.io/t/empty-results-for-front-end-filtering/20118>\
**Category:** How do I?\
**Created:** [October 6, 2025, 2:15pm UTC](https://community.weweb.io/t/empty-results-for-front-end-filtering/20118 "2025-10-06T14:15:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nealzie](https://avatars.discourse-cdn.com/v4/letter/n/958977/32.png) [@nealzie](https://community.weweb.io/u/nealzie)\
**Post date:** [October 6, 2025, 2:15pm UTC](https://community.weweb.io/t/empty-results-for-front-end-filtering/20118/1 "2025-10-06T14:15:35Z")

</div>

I have a search with autocomplete input. I use it’s value to search through a collection by using weweb’s own ‘frontend’ filters. Now I have a text element for when the filtered collection results are empty, however how can I bind its display condition to that filtered result?

 ![Screenshot 2025-10-06 at 16.12.50](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/b/b184f07b862426f03a43530d90ae51d4a19790de.png)

---

<div class="post-metadata">

**Author:** ![Kawwl](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kawwl/32/14297_2.png) [@Kawwl](https://community.weweb.io/u/Kawwl)\
**Post date:** [October 7, 2025, 7:42am UTC](https://community.weweb.io/t/empty-results-for-front-end-filtering/20118/2 "2025-10-07T07:42:54Z")

</div>

Hey, Niels

Probably not the answer your looking for, but I usually do this with AI, cause its simpler.  
Either in ChatGPT, (or your preferred LLM) or try WeWeb AI.

---

<div class="post-metadata">

**Author:** ![nealzie](https://avatars.discourse-cdn.com/v4/letter/n/958977/32.png) [@nealzie](https://community.weweb.io/u/nealzie)\
**Post date:** [October 7, 2025, 7:59am UTC](https://community.weweb.io/t/empty-results-for-front-end-filtering/20118/3 "2025-10-07T07:59:08Z")

</div>

Thanks Karl,

Problem is you can’t really reference these filtered results in weweb’s AI. Only the non-filtered object which stays the same while using front-end filters. (Plus since the last update I haven’t been able to get 1 good formula out of the AI anymore)

---

<div class="post-metadata">

**Author:** ![Kawwl](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kawwl/32/14297_2.png) [@Kawwl](https://community.weweb.io/u/Kawwl)\
**Post date:** [October 7, 2025, 8:59am UTC](https://community.weweb.io/t/empty-results-for-front-end-filtering/20118/4 "2025-10-07T08:59:31Z")

</div>

You want to do this in Javascript. I don’t know your filters but something like this:

```auto
const userGear = context.component?.variables?.['YOUR_WEWEB_VARIABLE_ID'] || [];

// Example: filter only active gear
const filtered = userGear.filter(item => item.status === 'active');

// Return true/false if filtered length is more than 0
return filtered.length > 0;

```

---

<div class="post-metadata">

**Author:** ![nealzie](https://avatars.discourse-cdn.com/v4/letter/n/958977/32.png) [@nealzie](https://community.weweb.io/u/nealzie)\
**Post date:** [October 7, 2025, 9:12am UTC](https://community.weweb.io/t/empty-results-for-front-end-filtering/20118/5 "2025-10-07T09:12:26Z")

</div>

Hi Karl, I appreciate the help!  
So for one of the filters (‘active’ indeed) that’s a static filter. My challenge lies in the search input which is a dynamic filter. I guess that would still work with your javascript (?).

 ![Screenshot 2025-10-07 at 11.09.40](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/0/0208648d9020a283b6170581536be5f1e9397628.png)

---

<div class="post-metadata">

**Author:** ![Kawwl](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kawwl/32/14297_2.png) [@Kawwl](https://community.weweb.io/u/Kawwl)\
**Post date:** [October 7, 2025, 11:10am UTC](https://community.weweb.io/t/empty-results-for-front-end-filtering/20118/6 "2025-10-07T11:10:02Z")

</div>

Yes that would work. So for an LLM (Chat GPT or any you prefer), i would paste something like this and see what it gives you. It’s a bit hard when i don’t know the details, but maybe you’ll get it.

```auto
const userGear = context.component?.variables?.['YOUR_WEWEB_VARIABLE_ID'] || [];
const sizeVar = [YOUR SIZE VARIABLE]
const productVar = [YOUR PRODUCT VARIABLE]

I want to return true or false. userGear is an array. Filter userGear by userGear.status == active. AND (userGear.size contains sizeVar OR userGear.product_item contains productVar). If the result length is 0, return false, else return true.

```

It should spit out some code. Here’s what i got with my dummy. If you input the correct variables, it will give you the code with the correct variables.

```auto
const userGear = context.component?.variables?.['YOUR_WEWEB_VARIABLE_ID'] || [];
const sizeVar = context.component?.variables?.['YOUR_SIZE_VARIABLE_ID'];
const productVar = context.component?.variables?.['YOUR_PRODUCT_VARIABLE_ID'];

const filtered = userGear.filter(g =>
  g.status === 'active' &&
  (
    (Array.isArray(g.size) ? g.size.includes(sizeVar) : g.size === sizeVar) ||
    (Array.isArray(g.product_item) ? g.product_item.includes(productVar) : g.product_item === productVar)
  )
);

return filtered.length > 0;

```
