Ver Mensaje Individual
  #3 (permalink)  
Antiguo 31/10/2008, 11:35
matak
 
Fecha de Ingreso: julio-2008
Ubicación: Alcañiz-Teruel-España
Mensajes: 182
Antigüedad: 15 años, 10 meses
Puntos: 5
Respuesta: Ayuda urgenteeeeeeeeeee

Eso que quieres hacer se puede hacer, pero con Ajax,...Estas en el foro equivocado

aunque bueno te puedo pasar un ejemplito sencillo

Pe. Tabla prueba (id,nombre,dir,localidad,provincia,telf)

index.php

Código javascript:
Ver original
  1. <script>
  2. function objetoAjax(){
  3.     var xmlhttp=false;
  4.     try {
  5.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  6.     } catch (e) {
  7.         try {
  8.            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  9.         } catch (E) {
  10.             xmlhttp = false;
  11.     }
  12.     }
  13.  
  14.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  15.         xmlhttp = new XMLHttpRequest();
  16.     }
  17.     return xmlhttp;
  18. }
  19.  
  20. function bucarDatos(pagina) {
  21.  
  22.         cadena=document.getElementById('nom');
  23.         pagina=pagina+"?cadena="+cadena;
  24.     TRcontenido = document.getElementById('TRcontenido');
  25.     ajax=objetoAjax();
  26.     ajax.open("POST", datos,true);
  27.     ajax.onreadystatechange=function() {
  28.         if (ajax.readyState==4) {
  29.             divcontenido.innerHTML = ajax.responseText
  30.         }
  31.     }
  32.     ajax.send(null);
  33.  
  34. }
  35.  
  36. </script>
  37.  
  38. <table>
  39.   <tbody>
  40.     <tr>
  41.       <td>
  42.         Nombre:<input type="text" name="nom" id="nom" value="" onblur="javascript:buscarDatos('buscarDatos.php');" />
  43.       </td>
  44.     </tr>
  45.     <tr id="TRcontenido">
  46.       <td>
  47.         Direcci&#243;n<input type="text" name="dir" id="dir" value="" />
  48.         <br/>
  49.         Tel&#233;fono<input type="text" name="tel" id="tel" value="" />
  50.       </td>
  51.       <td>
  52.         Localidad<input type="text" name="loc" id="loc" value="" />
  53.         <br/>
  54.         Provincia<input type="text" name="prov" id="prov" value="" />
  55.       </td>
  56.     </tr>
  57.   </tbody>
  58. </table>

buscarDatos.php

Código php:
Ver original
  1. <?PHP
  2.       $nombre=$_REQUEST['cadena'];
  3.       $conexion = mysql_connect ($host, $user,$pass)
  4.          or die ("No se puede conectar con el servidor");
  5.  
  6.       mysql_select_db ($BD)
  7.          or die ("No se puede seleccionar la base de datos");
  8.       $instruccion="SELECT * FROM tuTabla WHERE nombre='$nombre'";
  9.  
  10.       $consulta = mysql_query ($instruccion, $conexion )
  11.          or die (mysql_error ($db));
  12.  
  13. if (mysql_num_rows($consulta)!=0){
  14.       $resultado = mysql_fetch_array ($consulta);
  15. ?>
  16.       <td>
  17.         Dirección<input type="text" name="dir" id="dir" value="<?PHP echo $resultado['dir']; ?>" />
  18.         <br/>
  19.         Teléfono<input type="text" name="tel" id="tel" value="<?PHP echo $resultado['tel']; ?>" />
  20.       </td>
  21.       <td>
  22.         Localidad<input type="text" name="loc" id="loc" value="<?PHP echo $resultado['localidad']; ?>" />
  23.         <br/>
  24.         Provincia<input type="text" name="prov" id="prov" value="<?PHP echo $resultado['provincia']; ?>" />
  25.       </td>
  26. <?PHP
  27. }else {
  28. ?>
  29.       <td>
  30.         Dirección<input type="text" name="dir" id="dir" value="" />
  31.         <br/>
  32.         Teléfono<input type="text" name="tel" id="tel" value="" />
  33.       </td>
  34.       <td>
  35.         Localidad<input type="text" name="loc" id="loc" value="" />
  36.         <br/>
  37.         Provincia<input type="text" name="prov" id="prov" value="" />
  38.       </td>
  39. <?PHP
  40. }
  41. ?>

Espero te sirva...no lo he probado asi que si da algun error me dices

Saludos
__________________
Si quieres puedes y si puedes debes. Imposible is nothing!!!