No momento, só consigo buscar os itens que estão na coluna BAIRRO
no índice [0]
, como faço para conseguir buscar por EMPREENDIMENTO no índice [1]
, COMPLEMENTO no índice 2
, e VALOR no índice 5
?
Abaixo, segue um print mostrando a tabela e o filtro de pesquisa:
E aqui, segue o código fonte de minha tabela
<table class="dataTable table table-bordered table-striped" id="myTable">
<thead>
<tr>
<th>BAIRRO</th>
<th>EMPREENDIMENTO</th>
<th>COMPLEMENTO</th>
<th>PROPRIETÁRIO</th>
<th>CONTATO</th>
<th>VALOR</th>
<th>CADASTRADO EM</th>
</tr>
</thead>
<tbody>
<?php
foreach ($propertyDetails as $agenciamento) {
echo "<tr>";
echo "<td>$agenciamento->bairro</td>";
echo "<td>$agenciamento->empreendimento</td>";
echo "<td>$agenciamento->apartamento</td>";
echo "<td>$agenciamento->proprietario</td>";
echo "<td>$agenciamento->contato</td>";
echo "<td>$agenciamento->valor</td>";
echo "<td>$agenciamento->cadastro</td>";
echo "</tr>";
}
?>
</tbody>
E aqui, meu código em JAVASCRIPT
<script>
function myFunction() {
// Declare variables
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0,1];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>