diff --git a/templates/parts.html b/templates/parts.html index fe15230..3467fb7 100644 --- a/templates/parts.html +++ b/templates/parts.html @@ -31,6 +31,10 @@ table.sortable tbody tr:nth-child(2n+1) td { text-overflow: ellipsis; } +.search-container { + padding: 10px; +} + @media only screen and (max-width: 480px) { /* horizontal scrollbar for tables if mobile screen */ @@ -177,9 +181,12 @@ table.sortable tbody tr:nth-child(2n+1) td {
@@ -262,6 +269,37 @@ document.addEventListener('DOMContentLoaded', function () { }); }); + +function searchFunction() { + // Get input element and filter value + var input = document.getElementById('searchInput'); + var filter = input.value.toUpperCase(); + + // Get the table and its rows + var table = document.getElementById('data'); + var rows = table.getElementsByTagName('tr'); + + // Loop through all rows (skip the header row) + for (var i = 1; i < rows.length; i++) { + var cells = rows[i].getElementsByTagName('td'); + var rowMatches = false; + + // Loop through each cell in the row + for (var j = 0; j < cells.length; j++) { + var cellContent = cells[j].textContent || cells[j].innerText; + if (cellContent.toUpperCase().indexOf(filter) > -1) { + rowMatches = true; + break; + } + } + + // Show or hide the row based on the match + rows[i].style.display = rowMatches ? '' : 'none'; + } +} + + + |
---|