// Filter-search a table // Code expanded from this source: https://www.w3schools.com/howto/howto_js_filter_table.asp function filter() { let selector, val; selector = document.getElementsByName("select"); // Loop through the radio buttons to determine the filter-settings for (let i = 0; i < selector.length; i++) { if (selector[i].checked) { val = parseInt(selector[i].value); break; } } let input, insensitive, table, tr, td, txtValue; input = document.getElementById("search_history"); insensitive = input.value.toUpperCase(); table = document.getElementById("history"); tr = table.getElementsByTagName("tr"); // Loop through all table rows, and hide those that don't match the search query for (let i = 0; i < tr.length; i++) { td = tr[i].getElementsByTagName("td")[val]; if (td) { txtValue = td.textContent || td.innerText; if (txtValue.toUpperCase().indexOf(insensitive) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } }