Passar valores do pop up para meu form .
Galera é o seguinte.
Nao manjo muito de javascript...
A minha duvida é a seguinte :
Tenho um formulario que antes de prenchê-lo clico no botao procurar ... que abrirá uma pop up que contem uma lista de nomes cadastrados no banco.
Ate ai beleza. Quero que ao clicar em um nome qualquer da lista ... a pop up feche e retorne para mim nos campos input do meu form o valor nome o rg e o cpf desse cliente., para mim continuar o prenchimento do formulario depois...
Fiz rapidinho uma index.php com um form e o botao procurar.. que busca a pagina detalhes.php que lista os nomes.
Isso so para testar ...
Segue abaixo os scripts.
index.php
>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml%22)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #333333;
}
-->
</style>
</head>
<script language="JavaScript" src="selecionar_campo.js"></script>
<body>
<form id="form" name="form" method="post" action="">
<p class="style1"><a href="java script:window.open('detalhes.php','','width=450,height=340,top=0,left=0,scrollbars=yes');window.history.go(9)">Procurar <img src="lupa.gif" width="15" height="15" /></a></p>
<p class="style1">Nome:
<label>
<input name="nome" type="text" id="nome" onclick="window.open('detalhes.php','janela','adress=no')">
</label>
RG:
<label>
<input name="rg" type="text" id="rg" />
</label>
CPF:
<input name="cpf" type="text" id="cpf" />
</p>
</form>
</body>
</html>
detalhes.php
>
<html>
<head>
<title>..:: Detalhes ::..</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="fontes.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#000099" vlink="#000099" alink="#990000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="imagens/spacer.gif" width="1" height="3"></td>
</tr>
</table>
<?php
include("conexao.php");
$conexao = mysql_connect("$host","$user","$pass");
$db = mysql_select_db("$db");
$sql = "SELECT * FROM cad_func";
$resultado = mysql_query($sql)
or die ("Não foi possível realizar a consulta ao banco de dados");
$total = mysql_query($sql);
$total = mysql_num_rows($total);
echo "
<table width='600' border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#003399'>
<tr>
<td height='22' background='imagens/fundo_titulos.jpg' bgcolor='#F7F7F7'>
<p class='Texto_form_center'>Detalhes</p></td>
</tr>";
$resultado=mysql_query($sql);
while ($linha=mysql_fetch_array($resultado)) {
$id = $linha["id"];
$nome = $linha["nome"];
$cpf = $linha["cpf"];
$rg = $linha["rg"];
echo "
<tr>
<td bgcolor='#FFFFFF'>
<p class='Texto_form_esquerda'>";
if (strlen($nome)<1) {} else { echo "<strong>Nome:</strong> $nome. "; }
}
echo "</table>";
?>
<p class="Texto_form_centro"><input name="cadastrar" type="button" onClick="java script:window.close()" id="cadastrar" style="color: #000000; font-family: Verdana; font-size: 13 px; border-style: outset; border-width: 1; background-color: #CCCCCC" value="..:: Fechar ::..">
</p>
</html>
Procurei no forum mas os posts relacionados nao consegui resolver
Discussão (26)
Carregando comentários...