2014-01-15 90 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