CMS Development


DropDown for Country List not Showing from HubDB

Hello there, I created a small dropdown of countries listed for representatives in the area. I did this for representatives in the US with the same code and it worked correctly. I may not be filtering the country code correctly and was wondering if anyone can double check my code for me?


The name of the column label in my database is 'country' so I found it odd it's not 'matching up' for me.

Here is my mock site. Drop down works for 'Show All" but the countrie reps don't pop up and says theres no listings for that search. Thank you ! 🙂

{% set int_country_ID = 1 %}

<!-- set the filter -->

<form id="form_id" method="get">
        <h4>FILTER BY COUNTRY: </h4>
        <select name="country" form="form_id" onChange="this.form.submit()">
            <option value="show-all">Show All</option>
            {% set countrys = hubdb_table_column(5422908, "country").options %}
            {% for choice in countrys %}
                {% set country_list =|list%}
                {% if ==}
                    <option selected="selected" value="{{ }}">{{ }}</option>
                {% else %}
                    <option value="{{ }}">{{ }}</option>
                {% endif %}
            {% endfor %}
        <input name="name" type="text" id="search-by" class="autocomplete" placeholder="Search by name...">
        <input id="submit-button" type="submit" value="search">
  <input type="button" onclick="location.href='';" value="Show All" />
  <input type="button" onclick="location.href='';" value="View United States Consultants" />

<!-- sets the different query parameters using submitted input for hubdb query -->
{% set queryparam = "" %}
{% if in ["1", "2", "3", "4", "5", "6"] and == "" %}
    {% set queryparam = queryparam ~ "&country="|urlencode %}
{% endif %}
{% if in ["1", "2", "3", "4", "5", "6"] and != "" %}
    {% set queryparam = queryparam~"&country="|urlencode~"&zip__icontains="|urlencode %}
{% endif %}
{% if == "show-all" and != "" %}
    {% set queryparam = queryparam~"&name__icontains="|urlencode %}
{% endif %}

{% set table = hubdb_table_rows(5422908, queryparam) %}

<!-- Check if table exists, set sort by country -->
{% if table == [] %}
    <p class='align-center'>Sorry, no listings found for that search. Try changing your filter and search again.</p>
{% else %}
  {% for row in table|sort(False, False, 'country') %}

<div class="consultant-listing">
<h2>{{ row["name"] }}</h2>
              <p><b>Locations: {{ row["address"] }} </b></p>

              <div class="information">
                <p>{{row["city"]}}, {{row["country"].name}}</p>
                  {{ row["phone"] }}

              <br><a href="{{row["website"]}}">{{row["website"]}}</a> 
                <br><a href="mailto:{{ row["email"] }}">{{ row["email"] }}</a>
                       <div class="location_details">{{ row["location_details"] }}</div>

  {% endfor %}
  {% endif %}


2 Replies 2
Guide | Elite Partner
Guide | Elite Partner

DropDown for Country List not Showing from HubDB

Hi @unicorndev,


Have you changed the different values for the countries?

Perhaps the array you have created doesn't have the correct ID in it since you go from 1 till 6. ['1' .. '6'].


What you can do is view the corresponding ID from the current list you have by display the ID.

{% set countrys = hubdb_table_column(5422908, "country").options %}


So instead of doing 

{% if in ["1", "2", "3", "4", "5", "6"] and == "" %}


it's better do make it dynamic like this:

{% set countrys = hubdb_table_column(5422908, "country").options %}
{% if in countrys|map('id') %}


I also recommend checking out the HubDB documentation and tutorials:

  • HubDB 
  • There was a tutorial about a real Estate. You can ask HubSpot Support if it's still avalible.

Bureau Vet

Did my post solve your question? Help the community by marking it as a solution
Community Manager
Community Manager

DropDown for Country List not Showing from HubDB

Hey, @unicorndev 👋 I don't have the answer, but I do have some additional troubleshooting thoughts and questions.

To confirm:

For search, it works when searching by name — Roper returns only Roper, Calti returns only Calti, etc., but searching by county  is where you are having issues, correct? China returns nothing, same for Europe, Canada, and Australia.

For the dropdown issue, it works for China and Canada, but not Europe and Australia, correct? 





For the dropdown issue, I believe that is our biggest clue — why is it working 50% of the time?


Have a wonderful weekend! — Jaycee


Jaycee Lewis

Developer Community Manager

Community | HubSpot