anish117p
New Coder
Hi folks,
hope you are all well!
I have the below code running on a html. everytime i run it it also filters the header. could you kindly help.
thanking you inadvance.
<script>
function searchTable() {
var input, filter, found, table, tr, td, i, j;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("main-table");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr.getElementsByTagName("td");
for (j = 0; j < td.length; j++) {
if (td[j].innerHTML.toUpperCase().indexOf(filter) > -1) {
found = true;
}
}
if (found) {
tr.style.display = "";
found = false;
} else {
tr.style.display = "none";
}
}
}
</script>
hope you are all well!
I have the below code running on a html. everytime i run it it also filters the header. could you kindly help.
thanking you inadvance.
<script>
function searchTable() {
var input, filter, found, table, tr, td, i, j;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("main-table");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr.getElementsByTagName("td");
for (j = 0; j < td.length; j++) {
if (td[j].innerHTML.toUpperCase().indexOf(filter) > -1) {
found = true;
}
}
if (found) {
tr.style.display = "";
found = false;
} else {
tr.style.display = "none";
}
}
}
</script>