Ai galera blz? Eu to fazendo um site com um lugar para pesquisa em um bd interno. Antes os campos de pesquisa eram separados:
<form method="POST" action="executa1.php">
<table width="100%" border="0">
<tr>
<td><div align="center"><strong>Pesquisar: </strong></div></td>
</tr>
</table>
<table width="100%" height="149" border="1px" cellpadding="5px" cellspacing="0" id="alter">
<tr>
<td> CPF:</td>
<td><input name="cpf" type="text" size="20" maxlength="11"></td>
</tr>
<tr class="dif">
<td>Nome :</td>
<td><input name="nome" type="text" size="20" maxlength="60"></td>
</tr>
<tr >
<td>Nome da mãe : </td>
<td><input name="nome_mae" type="text" size="20" maxlength="60"></td>
</tr>
<tr class="dif">
<td>Nascimento:</td>
<td><input name="nascimento" type="text" size="20" maxlength="20"></td>
<td> <input type = "submit" name = "pesquisar" value = "Pesquisar"></td>
</tr>
</table>
mas decidi colocar uma SELECT ficando assim :
<form method="POST" action="executa1.php">
<table width="100%" border="0">
<tr>
<td><div align="center"><strong>Pesquisar </strong></div></td>
</tr>
</table>
<table width="100%" height="149" border="1px" cellpadding="0px" cellspacing="0" id="alter">
<tr>
<td> <select name="pesquisa" >
<option value="cpf">Cpf</option>
<option value="nome">Nome</option>
<option value="nome_mae">Nome da mãe </option>
<option value="nascimento">Nascimento</option> </select>
</td>
<td> <input name=" ?" type="text" size="20" maxlength="11"> </td>
</tr>
<tr>
<td> </td>
<td> <input type = "submit" name = "pesquisar" value = "Pesquisar"></td>
</tr>
</table>
mas não sei como transferir o valor da opcao escolhida para o input name.
Desde já grato pela ajuda!!!
Transferencia De Valores Entre Campos
Started By Macfall, 28/03/2007, 22:24
2 replies to this topic
#1
Posted 28/03/2007, 22:24
#2
Posted 29/03/2007, 08:59
porque não busca assim:
onde seu campo seja igual a pesquisa e valor igual ao valor do input.
onde seu campo seja igual a pesquisa e valor igual ao valor do input.
Edição feita por: linkprotegido.com, 29/03/2007, 09:03.
#3
Posted 29/03/2007, 16:42
Bem de forma geral o mais correto/semantico era trasferir o nome do campo a buscar para o PHP ....
Dai dentro do PHP ele faz a busca ... tipo assim:
Mas se ainda quizer JavaSCript ta ai ...
Dai dentro do PHP ele faz a busca ... tipo assim:
SELECT * FROM tabela WHERE $_POST["pesquisa"]=$_POST["busca"];
Mas se ainda quizer JavaSCript ta ai ...
<script language="JavaScript">
function MudaCampo(nome) {
document.getElementById("buscas").name = nome;
}
</script>
<select name="pesquisa" onChange="java script:MudaCampo(this.value);">
<option value="cpf">Cpf</option>
<option value="nome">Nome</option>
<option value="nome_mae">Nome da mãe </option>
<option value="nascimento">Nascimento</option>
</select>
<input name="cpf" type="text" size="20" maxlength="11" id="buscas" onClick="alert(this.name);">
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)











