- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Filtering through table data based off of select column
Jun 26, 2020 3:39 PM
<!-- Pulling the data from the table and assigning it to table -->
{% set people = hubdb_table_rows(2639483, queryparam) %}
<!-- This is where I get lost!! My program shows the select options, but will not filter once the user has selected an option from the form -->
<!-- sets the different query parameters using submitted input for hubdb query -->
{% set queryparam = "" %}
{% if request.query_dict.type in ["1", "2", "3", "4"] %}
{% set queryparam = queryparam ~ "&type="~request.query_dict.type|urlencode %}
{% endif %}
{% if request.query_dict.type == "show-all" %}
{% set queryparam = queryparam %}
{% endif %}
<form id="form_id" method="get">
<select name="flavor_options" form="form_id" onChange="this.form.submit()">
<option value="show-all">Show All</option>
<!-- Set flavor options to their values to make search function work -->
{% set flavor_options = hubdb_table_column(2639483, "favorite_ice_cream").options %}
{% for choice in flavor_options %}
{% set flavor_list = flavor_list~choice.id|list%}
{% if choice.id == request.query_dict.flavor_options%} <!-- flavor_options might need to be changed to type -->
<option selected="selected" value="{{ choice.id }}">{{ choice.name }}</option>
{% else %}
<option value="{{ choice.id }}">{{ choice.name }}</option>
{% endif %}
{% endfor %}
</select>
</form>
<!-- If the table is empty return a statement for the user to change their search parameters -->
{% if people == [] %}
<p class='align-center'>Sorry, no people match that criteria. Try changing your filter and search again.</p>
{% else %}
<!-- Loop through each row of data -->
{% for row in people %}
<h2>{{ row.name }} {{row.last_name}}</h2>
<p>Age: {{ row.age }}</p>
<i>
{% for flavor in row.favorite_ice_cream %}
<p>Favorite Ice Cream: {{ flavor.name }}</p>
{% endfor %}
</i>
{% endfor %}
{% endif %}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content