I have searched many pages for information on how to do a search with several filters in an html table.
That when searching, the data is typed in the first filter, and when entering the next data in the other filter, do not erase the data from the previous filter. I need to put several filters but none alter the search for the other.
HMTL code:
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Busqueda Central" title="Busqueda Rapida" class="form-control">
<table id=myTable>
<th>CODIGO</th>
<th>CIUDAD</th>
<th>CENTRAL</th>
<th>EQUIPO</th>
<th>TIPO DE EQUIPO</th>
<th>MARCA</th>
<th>MODELO</th>
<th>UNIDAD</th>
<th>CANTIDAD</th>
<tr>
..<td id="hola" valign="top" width="150" align="center"></td>
..<td id="hola" valign="top" width="150" align="center"></td>
..<td id="hola" valign="top" width="150" align="center"></td>
..<td id="hola" valign="top" width="150" align="center"></td>
..<td id="hola" valign="top" width="150" align="center"></td>
..<td id="hola" valign="top" width="150" align="center"></td>
..<td id="hola" valign="top" width="150" align="center"></td>
..<td id="hola" valign="top" width="150" align="center"></td>
..<td id="hola" valign="top" width="150" align="center"></td>
</tr>
</table>
Search engine code that I am using:
<script>
function myFunction() {
var input, filter, table, tr, td, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[3];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>