Mactos_Cohen Posted June 25, 2012 at 08:45 PM Report Share #465483 Posted June 25, 2012 at 08:45 PM Olá mais uma vez galera, Quero na input name="Nome" apareca o nome da ID selecionado na select name="id" eu fiz assim mas quando seleciono outro id o nome não muda. <?php include_once ("segura.php"); protPagina (); ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sem título</title> </head> <select name="id" onkeypress="return handleEnter(this, event)" > <?php $sql_lista_clientes = mysql_query("SELECT * FROM tb_clientes "); while ($resultado_clientes = mysql_fetch_array($sql_lista_clientes, MYSQL_ASSOC)){ $id_logado = $resultado_clientes ['id']; $nome = $resultado_clientes ['nome']; ?> <option><?php echo $id_logado ?> <?php } ?> </option> </select> <input name="Nome" type="text" maxlength="25" value="<?php echo $nome ?>" /> <body> </body> </html> Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted June 25, 2012 at 09:09 PM Report Share #465487 Posted June 25, 2012 at 09:09 PM pode ser mais explicito no que realmente pretendes ?? se não consegues, dá um exemplo IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Mactos_Cohen Posted June 26, 2012 at 04:19 PM Author Report Share #465714 Posted June 26, 2012 at 04:19 PM (edited) Ola, Quero num combobox selecionar o ID do cliente e na textbox aparecer o nome dele exemplo, id nome 1 Mactos 2 Manuel Edited June 26, 2012 at 04:19 PM by Mactos_Cohen Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted June 26, 2012 at 04:25 PM Report Share #465716 Posted June 26, 2012 at 04:25 PM - ou crias um array em javascript que será lido após a selecção do ID - ou usas AJAX para depois da selecção, é feito um pedido ao servidor do texto a ser apresentado - ou ainda existe uma solução muito simplista que é o uso de atributos não standard no option onde guardas o texto, ao seleccionar o id, esse texto será copiado para o input IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Mactos_Cohen Posted June 26, 2012 at 08:16 PM Author Report Share #465768 Posted June 26, 2012 at 08:16 PM ok, obrigado vou usar AJAX, Obrigado. Link to comment Share on other sites More sharing options...
taviroquai Posted June 27, 2012 at 03:20 AM Report Share #465815 Posted June 27, 2012 at 03:20 AM Boa noite, A estrutura do html que colocou é inválida e pode dar origem a muitos outros erros. Tente construir html válido antes de avançar com as correções de php ou javascript. Link to comment Share on other sites More sharing options...
ivobarbosa Posted July 19, 2012 at 02:26 PM Report Share #469247 Posted July 19, 2012 at 02:26 PM Olá mais uma vez galera, Quero na input name="Nome" apareca o nome da ID selecionado na select name="id" eu fiz assim mas quando seleciono outro id o nome não muda. <?php include_once ("segura.php"); protPagina (); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%22> <html xmlns="http://www.w3.org/1999/xhtml%22> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sem título</title> </head> <select name="id" onkeypress="return handleEnter(this, event)" > <?php $sql_lista_clientes = mysql_query("SELECT * FROM tb_clientes "); while ($resultado_clientes = mysql_fetch_array($sql_lista_clientes, MYSQL_ASSOC)){ $id_logado = $resultado_clientes ['id']; $nome = $resultado_clientes ['nome']; ?> <option><?php echo $id_logado ?> <?php } ?> </option> </select> <input name="Nome" type="text" maxlength="25" value="<?php echo $nome ?>" /> <body> </body> </html> Este código <select name="id" onkeypress="return handleEnter(this, event)" > <?php $sql_lista_clientes = mysql_query("SELECT * FROM tb_clientes "); while ($resultado_clientes = mysql_fetch_array($sql_lista_clientes, MYSQL_ASSOC)){ $id_logado = $resultado_clientes ['id']; $nome = $resultado_clientes ['nome']; ?> <option><?php echo $id_logado ?> <?php } ?> </option> </select> <input name="Nome" type="text" maxlength="25" value="<?php echo $nome ?>" /> devia estar dentro da tag BODY Melhores Cumprimentos, Ivo Barbosa Link to comment Share on other sites More sharing options...
Rui Carlos Posted July 19, 2012 at 10:05 PM Report Share #469291 Posted July 19, 2012 at 10:05 PM Para além do problema do body, a tag </option> também deveria estar dentro do ciclo. 1 Report Rui Carlos Gonçalves Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted July 19, 2012 at 10:34 PM Report Share #469295 Posted July 19, 2012 at 10:34 PM Boa noite, A estrutura do html que colocou é inválida e pode dar origem a muitos outros erros. Tente construir html válido antes de avançar com as correções de php ou javascript. IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now