Ver Mensaje Individual
  #5 (permalink)  
Antiguo 31/03/2012, 07:50
Avatar de gjx2
gjx2
 
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 16 años, 5 meses
Puntos: 139
Respuesta: llamar funcion php con javaScrip y ejecutar

Una manera rapida y simple es utilizar jquery


Código Javascript:
Ver original
  1. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="application/javascript"></script>
  2. <script type="text/javascript">
  3.    
  4.     $(document).ready(function(e) {
  5.        
  6.        
  7.        /* texto es el id de tu textBox */
  8.        $("#texto").keypress(function(event) {
  9.        
  10.  if ( event.which == 13 ) {
  11.          event.preventDefault();
  12.            
  13.             /* Llamo la funcion que consultara el archivo php */
  14.              urlPhp();
  15.    }
  16. });
  17.        
  18.     });
  19.  
  20.  
  21.     function urlPhp()
  22.     {  
  23.    
  24.    
  25.             $.ajax({
  26.                
  27.                 /* Aqui va la url del archivo php ej. http://127.0.0.1/archivo.php  */
  28.                 url:'',
  29.                 success:function(d){
  30.                     /* Aqui capturo el resultado de la funcion del archivo php */  
  31.  
  32. /* Id del div donde quieres mostrar el resultado ej. $('#mostrar').html(d) */
  33.                         $('#').html(d);
  34.                     },
  35.                
  36.                 }) 
  37.     }
  38.  
  39. </script>

Código HTML:
Ver original
  1. texto: <input type="text" name="texto"  id="texto" />