# HubDB Filters

**URL:** <https://community.hubspot.com/t/hubdb-filters/48768>\
**Category:** CMS Development\
**Tags:** hubdb\
**Created:** [December 17, 2021, 8:55pm UTC](https://community.hubspot.com/t/hubdb-filters/48768 "2021-12-17T20:55:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JLamb14](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jlamb14/32/29777_2.png) [@JLamb14](https://community.hubspot.com/u/JLamb14)\
**Post date:** [December 17, 2021, 8:55pm UTC](https://community.hubspot.com/t/hubdb-filters/48768/1 "2021-12-17T20:55:27Z")

</div>

Hello,

I am working on a page listing remote notaries, and I need assistance with a filter and search bar.

I am attempting to filter by state (state\_commissioned) and to add a search bar that will allow searching by name (hs\_name). I’m able to get the state options to show up in the filter, but nothing is happening when the option is selected.

I have attached where I’m at below:

```lia-code-sample
<!-- set the filter by drop down, search bar, and submit button -->
<div>
 <form id="form_id" method="get">
 <div>
 <h4>Filter By State: </h4>
 <select name="type" form="form_id" onChange="this.form.submit()">
 <option value="show-all">Show All</option>
 {% set contact = hubdb_table_column(5312178, "state_filter").options %} {% for choice in contact %} {% set type_list = type_list~choice.id|list %} {% if choice.id == request.query_dict.contact %}
 <option selected="selected" value="{{ choice.id }}">{{ choice.name }}</option>
 {% else %}
 <option value="{{ choice.id }}">{{ choice.name }}</option>
 {% endif %} {% endfor %}
 </select>
 </div>
 <div>
 <input name="city" type="text" id="search-by" class="autocomplete" placeholder="Search by Name">
 </div>
 <input id="submit-button" type="submit" value="search">
 </form>
 <!-- sets the different query parameters using submitted input for hubdb query -->
{% set queryparam = "" %}
{% if request.query_dict.type in ["1", "2", "3", "4"] and request.query_dict.state_filter == "" %}
 {% set queryparam = queryparam ~ "&type="~request.query_dict.type|urlencode %}
{% endif %}
{% if request.query_dict.type in ["1", "2", "3", "4"] and request.query_dict.state_filter != "" %}
 {% set queryparam = queryparam~"&type="~request.query_dict.type|urlencode~"&state_filter__icontains="~request.query_dict.state_filter|urlencode %}
{% endif %}
{% if request.query_dict.type == "show-all" and request.query_dict.state_filter != "" %}
 {% set queryparam = queryparam~"&hs_name__icontains="~request.query_dict.state_filter|urlencode %}
{% endif %}
</div>

{# Get eNotary Network Members from HubDB #}
{% set queryParam = 'orderBy=random()' %}
{% set table = hubdb_table_rows(5312178, queryParam)%}

{% if table == [] %}
 <p class='align-center'>Sorry, no one found for that Search. Try changing your filter and search again.</p>
{% else %}
 {% for row in table %}
<html>
 <head>
 <script src="https://kit.fontawesome.com/a2aef4b109.js" crossorigin="anonymous"></script>
 </head>
 <body>
 <div class="grid-container">
 <div class="image">
 <img src="{{ row["enotary_photo"].url }}">
 </div>
 <div class="text">
 <h4>{{ row.enotary_name }}</h4>
 <h5>{{ row.enotary_company }} </h5>
 <div><b>Time zone: </b>{{ row.time_zone }}</div>
 <div>
 <b>State: </b>{{ row.state_commissioned }}</div>
 <div><i class="fa fa-envelope" style="font-size:18px;color:#568ea3;vertical-align: text-top;"> </i>{{ row.enotary_email }}  </div>
 <div><i class="fa fa-phone" style="font-size:18px;color:#568ea3;vertical-align: text-top;"> </i>{{ row.enotary_phone}}</div>
 </div>
 <div class="certification">
 <img src="{{ row["signix_certifitied"].url }}">
 </div>
 </div>
 </body>
</html>
{% endfor %}
{% endif %}

```

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [December 20, 2021, 6:32pm UTC](https://community.hubspot.com/t/hubdb-filters/48768/2 "2021-12-20T18:32:17Z")

</div>

@Anton , have any thoughts on this?

---

<div class="post-metadata">

**Author:** ![Anton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/anton/32/103167_2.png) [@Anton](https://community.hubspot.com/u/Anton)\
**Post date:** [December 29, 2021, 9:20am UTC](https://community.hubspot.com/t/hubdb-filters/48768/3 "2021-12-29T09:20:23Z")

</div>

Hi @JLamb14,

try changing the code as follows:

```lia-code-sample
{% require_js %}
<script src="https://kit.fontawesome.com/a2aef4b109.js" crossorigin="anonymous"></script>
{% end_require_js %}

<!-- set the filter by drop down, search bar, and submit button -->
<div>
 <form id="form_id" method="get">
 <div>
 <h4>Filter By State: </h4>
 <select name="type" form="form_id" onChange="this.form.submit()">
 <option value="show-all">Show All</option>
 {% set contact = hubdb_table_column(5312178, "state_filter").options %} 
				{% for choice in contact %}
				{% set type_list = type_list~choice.id|list %} 
				{% if choice.id == request.query_dict.contact %}
 <option selected="selected" value="{{ choice.id }}">{{ choice.name }}</option>
 {% else %}
 <option value="{{ choice.id }}">{{ choice.name }}</option>
 {% endif %} {% endfor %}
 </select>
 </div>
 <div>
 <input name="city" type="text" id="search-by" class="autocomplete" placeholder="Search by Name">
 </div>
 <input id="submit-button" type="submit" value="search">
 </form>
 <!-- sets the different query parameters using submitted input for hubdb query -->

</div>

{% set queryparam = "" %}
{% if request.query_dict.type in ["1", "2", "3", "4"] and request.query_dict.state_filter == "" %}
 {% set queryparam = queryparam ~ "&type="~request.query_dict.type|urlencode %}
{% endif %}
{% if request.query_dict.type in ["1", "2", "3", "4"] and request.query_dict.state_filter != "" %}
 {% set queryparam = queryparam~"&type="~request.query_dict.type|urlencode~"&state_filter__icontains="~request.query_dict.state_filter|urlencode %}
{% endif %}
{% if request.query_dict.type == "show-all" and request.query_dict.state_filter != "" %}
 {% set queryparam = queryparam~"&hs_name__icontains="~request.query_dict.state_filter|urlencode %}
{% endif %}

{# Get eNotary Network Members from HubDB #}
{% set queryParam = queryparam ~ 'orderBy=random()' %}
{% set table = hubdb_table_rows(5312178, queryParam)%}

{% if table == [] %}
 <p class='align-center'>Sorry, no one found for that Search. Try changing your filter and search again.</p>
{% else %}
 {% for row in table %}
 <div class="grid-container">
 <div class="image">
 <img src="{{ row["enotary_photo"].url }}">
 </div>
 <div class="text">
 <h4>{{ row.enotary_name }}</h4>
 <h5>{{ row.enotary_company }} </h5>
 <div><b>Time zone: </b>{{ row.time_zone }}</div>
 <div>
 <b>State: </b>{{ row.state_commissioned }}</div>
 <div><i class="fa fa-envelope" style="font-size:18px;color:#568ea3;vertical-align: text-top;"> </i>{{ row.enotary_email }} </div>
 <div><i class="fa fa-phone" style="font-size:18px;color:#568ea3;vertical-align: text-top;"> </i>{{ row.enotary_phone}}</div>
 </div>
 <div class="certification">
 <img src="{{ row["signix_certifitied"].url }}">
 </div>
 </div>
{% endfor %}
{% endif %}

```

best,

Anton
