mcgufa Posted March 28, 2019 Share Posted March 28, 2019 i have a table of songs"links" and i am trying to make a search bar for them but i cant seem to figure it out, would anyone be so kind to help me? S3RL (WIP).html Link to comment Share on other sites More sharing options...
Funce Posted April 1, 2019 Share Posted April 1, 2019 Well.... it works nicely enough, and you just need to modify your js to search all columns, rather than just the first one. Example at end. But the rest of your code could probably use a pass through the W3 HTML checker, that was... an experience to look through. BR's, fonts and centers. Not my idea of a good time. https://validator.w3.org function myFunction() { var input, filter, table, tr, td, i, txtValue, show; input = document.getElementById("myInput"); filter = input.value.toUpperCase(); table = document.getElementById("myTable"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { show = false; td = tr[i].getElementsByTagName("td"); for(j = 0; j < td.length; j++){ if (td[j]) { txtValue = td[j].textContent || td[j].innerText; if (txtValue.toUpperCase().indexOf(filter) > -1) { show = true; } } } if (show) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now