Originariamente inviato da kontimatteo
Come hai risolto...??? Mi interesserebbe...
così:
codice:
<html>
<head>
<script type="text/javascript">
function Ricerca(valore){
tdh=document.getElementById("tabella").tHead.rows[0].cells;
for(i=0;i<tdh.length;i++){
htext=tdh[i].firstChild.nodeValue;
if(htext=="nome")
colonna=i;
}
trs=document.getElementById("tabella").tBodies[0].rows;
for(i=0;i<trs.length;i++){
testo=trs[i].cells[colonna].firstChild.nodeValue;
testo=testo.toUpperCase();
if(testo.indexOf(valore.toUpperCase())==-1) trs[i].style.display="none";
}
}
function Ripristina(){
trs=document.getElementById("tabella").tBodies[0].rows;
for(i=0;i<trs.length;i++){
trs[i].style.display="";
}
}
function Cerca() {
this.Ripristina();
testo = document.Ricerca.nome.value;
this.Ricerca(testo);
}
onload = function () {
if(document.getElementById){
document.getElementById("t1ricerca").style.display="block";
document.getElementById("t2ricerca").style.display="block";
}
}
</script>
</head>
<body>
<form name="Ricerca">
<input type="text" name="nome" value="" onKeyUp="Cerca()">
</form>
<table id="tabella">
<thead>
<tr>
<th>nome</th>
<th>codice</th>
</tr>
</thead>
</tfoot>
<tbody>
<tr>
<td>html</td>
<td>C001</td>
</tr>
<tr>
<td>it</td>
<td>C002</td>
</tr>
<tr>
<td>ciao</td>
<td>C003</td>
</tr>
<tr>
<td>giuseppe</td>
<td>C004</td>
</tr>
<tr>
<td>carlo</td>
<td>C005</td>
</tr>
<tr>
<td>mario</td>
<td>C006</td>
</tr>
</tr>
</tbody>
</table>
</body>
</html>
essenziali il <th></th>, la tabella deve chiamarsi, cioè l'id "tabella". Volendo puoi passare il campo come parametro.
ciao