2014-01-15 66 views
0

我有使用jQuery做了搜索..隐藏jQuery的表行

<script type="text/javascript" src="ajax.js"></script> 
<div style="width:400px; margin:auto;"> 
<form action="clientes.php" method="post"> 
    <legend>Procurar cliente</legend> 
    <input type="text" id="nome" name="nome" value="<?php echo $nome; ?>" style="width: 280px; height: 23px;" /><input type="button" name="btnPesquisar" value="Pesquisar" onclick="getDados();"/></form> 
</div> 
<div id="resultado"></div> 

和getDados返回从另一个页面,这就是结果:

<?php 
header('Content-Type: text/html; charset=utf-8'); 
include "conexao.php"; 
if ($_GET['nome']) { 
$nome = $_GET['nome']; 
$result = mysql_query("SELECT * FROM cliente WHERE nome LIKE '%".$nome."%' OR cpf LIKE  '%".$nome."%' ORDER BY nome ASC") or die('Invalid query: ' . mysql_error()); 
$num_rows = mysql_num_rows($result); 
} 

if ($num_rows != 0) { 
?> 
<head><script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"> </script></head> 
<script type="text/javascript"> 
$(document).ready(function() { 
$('.hideme td').hide(); 
}); 
</script> 
<table border=4 width="800px" align="center"> 
<tr><th>Cliente</th> <th>CPF</th> <th>Telefone</th> <th> Aniversário </th><th> Endereço </th></tr> 
<?php 
$i = "1"; 
while ($row = mysql_fetch_assoc($result)) { 
?> 

<TR> 
<td width="220px" align="center"> <a href="#" onclick="document.forms['nomepost<?php echo $i; ?>'].submit();"><?php echo $row['nome']; ?></a> </td> 
<td width="80px" align="center"> <?php echo $row['cpf']; ?> </td> 
<td width="120px" align="center"><?php echo $row['telefone'] ?> </td> 
<td width="120px" align="center"><?php echo $row['dataNascimento']; ?></a></td> 
<td width="270px" align="center"><?php echo $row['endereco']; ?></td> 
</TR> 
<tr class="hideme"><td><form id="nomepost<?php echo $i; ?>" action="agrupaclienteteste.php" method="post"> 
<input type="hidden" name="nome" value="<?php echo $row['nome']; ?>"></form></td</tr> 
<?php 
$i++; 
} 
} 
else{ 
if ($nome) { echo "Não há dados cadastrados em nosso sistema."; } 
} 
?> 

现在..事情是如果我在自己独立运行的结果页面..可以说 result.php?诺姆= I

它隐藏了TR类= hideme ...
如果我访问搜索页面和搜索nome = I,它显示的结果,但它不隐藏tr class = hideme ...

任何人都可以帮助我吗?

+0

很难帮助没有看到getDados做什么。它是否发出ajax请求或是否将浏览器位置移动到结果页面?如果它发出ajax请求,你会怎么做才能让浏览器解释响应? – SnowInferno

回答

1

为什么不只是使用style="display:none;"作为属性值,因为你试图掩盖自己为onload

+0

为什么我不觉得简单?非常感谢 – ledesma