Generation

generate functionWed, 02 Aug 2023

add a search function to the table

function addSearch(){ var input, filter, table, tr, td, i; input = document.getElementById("search_input"); filter = input.value.toUpperCase(); table = document.getElementById("table_data"); 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"; } } } }

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant