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

Hola nuevamente, despues de pelear mucho encontre una manera de resolver mi problema, ahora me resta una cosita mas, necesito llenar dos textbox y no se como hacerlo.
Aca el codigo:

Archivo html
Código HTML:
Ver original
  1. //  Developed by Roshan Bhattarai
  2. //  Visit http://roshanbh.com.np for this script and more.
  3. //  This notice MUST stay intact for legal use
  4.  
  5. //fuction to return the xml http object
  6. function getXMLHTTP() {
  7.         var xmlhttp=false; 
  8.         try{
  9.             xmlhttp=new XMLHttpRequest();
  10.         }
  11.         catch(e)    {      
  12.             try{           
  13.                 xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
  14.             }
  15.             catch(e){
  16.                 try{
  17.                 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  18.                 }
  19.                 catch(e1){
  20.                     xmlhttp=false;
  21.                 }
  22.             }
  23.         }
  24.            
  25.         return xmlhttp;
  26.     }
  27.    
  28.    
  29.    
  30. function getCurrencyCode(strURL)
  31. {      
  32.     var req = getXMLHTTP();    
  33.     if (req)
  34.     {
  35.         //function to be called when state is changed
  36.         req.onreadystatechange = function()
  37.         {
  38.             //when state is completed i.e 4
  39.             if (req.readyState == 4)
  40.             {          
  41.                 // only if http status is "OK"
  42.                 if (req.status == 200)
  43.                 {                      
  44.                     document.getElementById('cur_code').value=req.responseText;
  45.                                        
  46.                 }
  47.                 else
  48.                 {
  49.                     alert("There was a problem while using XMLHTTP:\n" + req.statusText);
  50.                 }
  51.             }              
  52.          }         
  53.          req.open("GET", strURL, true);
  54.          req.send(null);
  55.     }
  56.                
  57. }
  58. </head>
  59.  
  60. <dl>
  61. <form  name="form1" id="form1">
  62.   <dd>Cheque Nº:</dd>
  63.     <dd>        
  64.      
  65.       <select id="nombre" name="nombre" onChange="getCurrencyCode('find_ccode.php?nombre='+this.value)">
  66.   <option value="0">Selecciona Uno...</option>
  67.   <?echo $varc?>
  68.       </select>
  69.     <dd>
  70.     <dd>
  71.       <input type="text" name="direccion" id="cur_code" />
  72.     <dd>
  73.       <input type="text" name="telefono" id="cur_code2" />
  74.     </form></body>
  75. </html>

Archivo find_ccode.php:

Código PHP:
Ver original
  1. <?php
  2. $nombre=$_REQUEST['nombre'];
  3.  
  4. $con = mysql_connect('localhost', 'root', '');
  5.  if (!$con)
  6.    {
  7.    die('Could not connect: ' . mysql_error());
  8.    }
  9.  
  10. mysql_select_db("base", $con);
  11.  
  12. $sql="SELECT * FROM usuarios WHERE nombre = '".$nombre."'";
  13.  
  14. $result = mysql_query($sql);
  15.  
  16. while($row = mysql_fetch_array($result))
  17.    {
  18.    echo $row['direccion'];
  19.    echo $row['telefono'];
  20.    }
  21.  
  22.  
  23. ?>

El problema que tengo es que no puedo hacer que se dividan los datos direccion y telefono en los distintos textbox