How can I set the selected choice to use it like a filter?
SOLVE
It only works if you have your query parameter in the URL that the HubL is looking for. Open the preview URL in a new window, then at the end add your "&name=1" and see if it works.
Aug 14, 20208:32 AM - edited Aug 14, 20208:32 AM
Key Advisor | Partner
How can I set the selected choice to use it like a filter?
SOLVE
@naixs looks like your using "city" as the name for that form input. If you are using a form the native browser way, it should add a query paremeter to your URL when you submit the form which should look like this example.com/page?city=new%20york
You can use HubL to look for that query parameter in the URL when the page refreshes to add the "selected" attribute.
Here's what that looks like with your code:
<select class="list-city dropdown" name="city">
{% set types = hubdb_table_column(module.hubdbtable_field, "city").options %}
{% for choice in types %}
<option {% if choice.name == request.query_dict.name %}selected{% endif %} value="{{ choice.name }}">{{ choice.name }}</option>
{% endfor %}
</select>
How can I set the selected choice to use it like a filter?
SOLVE
It only works if you have your query parameter in the URL that the HubL is looking for. Open the preview URL in a new window, then at the end add your "&name=1" and see if it works.