Filtering through table data based off of select column
<!-- 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 %}