Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/03/2013, 18:17
hernan2212
 
Fecha de Ingreso: marzo-2012
Ubicación: Rosario
Mensajes: 108
Antigüedad: 12 años, 1 mes
Puntos: 0
Pregunta Combobox + textbox

Hola, como estan? encontre un codigo que me puede servir para lo que estoy buscando pero no logro adaptarlo a mis necesidades, pido de su ayuda para poder hacerlo.

El codigo que tengo busca dentro de un select una opcion y completa con los demas datos un <div> yo necesito completar en ves del div varios textbox con los datos que recoje.

Aca el codigo:

Código HTML:
<html>
 <head>
 <script>
 function showUser(str)
 {
 if (str=="")
   {
   document.getElementById("txtHint").innerHTML="";
   return;
   } 
if (window.XMLHttpRequest)
   {// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
   }
 else
   {// code for IE6, IE5
   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
 xmlhttp.onreadystatechange=function()
   {
   if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
     document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
     }
   }
 xmlhttp.open("GET","getuser.php?q="+str,true);
 xmlhttp.send();
 }
 </script>
 </head>
 <body>
 
<form>
 <select name="users" onChange="showUser(this.value)">
 <option value="">Select a person:</option>
 <option value="182">Peter Griffin</option>
 <option value="2">Lois Griffin</option>
 <option value="3">Glenn Quagmire</option>
 <option value="4">Joseph Swanson</option>
 </select>
 </form>
 <br>
 <div id="txtHint"><b>Person info will be listed here.</b></div>
 
</body>
 </html> 
Archivo getuser.php
Código PHP:
<?php
 $q
=$_GET["q"];
 
$con mysql_connect('localhost''root''');
 if (!
$con)
   {
   die(
'Could not connect: ' mysql_error());
   }
 
mysql_select_db("base"$con);
 
$sql="SELECT * FROM user WHERE id = '".$q."'";
 
$result mysql_query($sql);
 
echo 
"<table border='1'>
 <tr>
 <th>Firstname</th>
 <th>Lastname</th>
 <th>Age</th>
 <th>Hometown</th>
 <th>Job</th>
 </tr>"
;
 
while(
$row mysql_fetch_array($result))
   {
   echo 
"<tr>";
   echo 
"<td>" $row['name'] . "</td>";
   echo 
"<td>" $row['lastname'] . "</td>";
   echo 
"<td>" $row['age'] . "</td>";
   echo 
"<td>" $row['hometown'] . "</td>";
   echo 
"<td>" $row['job'] . "</td>";
   echo 
"</tr>";
   }
 echo 
"</table>";
 
mysql_close($con);
 
?>
Gracias por la ayuda de antemano
Saludos!