我已经用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 class = hideme ...
如果我访问搜索页面并搜索nome = I,它会显示结果,但它不会隐藏tr class = hideme ...
任何人都可以帮助我吗?
答案 0 :(得分:1)
为什么不只使用style="display:none;"
作为属性值,因为您试图隐藏onload本身