1
I’ve made several attempts with this logic:
<html>
<head>
<script>
window.onload = function(){
var filtro = document.getElementById('nome').value;
var tabela = document.getElementById('lista');
filtro.onkeyup = function() {
var nomeFiltro = filtro.value;
for (var i = 1; i < tabela.rows.length; i++) {
var conteudoCelula = tabela.rows[i].cells[0].textContent;
var corresponde = conteudoCelula.toLowerCase().indexOf(nomeFiltro) >= 0;
tabela.rows[i].style.display = corresponde ? '' : 'none';
}
}
}
</script>
</head>
<body>
<table id="lista">
<thead>
<tr>
<th><div><input type="text" id="nome" value=""/></div></th>
<th>Telefone</th>
<th>Ramal</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ana</td>
<td>3333-3333</td>
<td>123</td>
</tr>
<tr>
<td>Pedro</td>
<td>3333-3333</td>
<td>123</td>
</tr>
<tr>
<td>Luiz</td>
<td>3333-3333</td>
<td>123</td>
</tr>
<tr>
<td>Maria</td>
<td>3333-3333</td>
<td>123</td>
</tr>
<tr>
<td>Rodrigo</td>
<td>3333-3333</td>
<td>123</td>
</tr>
<tr>
<td>Silvana</td>
<td>3333-3333</td>
<td>123</td>
</tr>
</tbody>
</table>
</body>
</html>
For now nothing has worked ...
And again, thanks for the help. It’s cool!!! consider my vote.
– Diego Henrique