Hi am trying to make a filter for my table with a drop down list but i got some problems with that it doesent do anything. The drop down list get its data from sqlite db but if i do not use a db and write the options in the html file it works.
Here is the lines of code for the drop down list.
List.html
Here is the lines of code for the drop down list.
List.html
<select id="mylist" onchange="myFunction2()" class='form-control'> {% for data in datas %} <option value="{{ data.anstallda }}">{{ data.Namn }}</option> {% endfor %} </select> function myFunction2() { var input, filter, table, tr, td, i; input = document.getElementById("mylist"); filter = input.value.toUpperCase(); table = document.getElementById("myTable"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td")[0]; if (td) { if (td.innerHTML.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } }From the python file
@app.route('/list') def list(): con = sql.connect("database.db") con.row_factory = sql.Row cur = con.cursor() cur.execute("select * from tider") rows = cur.fetchall(); cur.execute("SELECT * FROM anstallda") datas = cur.fetchall(); return render_template("list.html",rows = rows, datas = datas)