Ver Mensaje Individual
  #4 (permalink)  
Antiguo 10/02/2011, 13:26
Stackado
 
Fecha de Ingreso: junio-2009
Mensajes: 75
Antigüedad: 14 años, 11 meses
Puntos: 0
Respuesta: ayuda metodo onchange

Hola

yo uso este codigo que funciona que al dar cierto numero ID y presionar enter, realiza una busqueda en una BD y lo regresa con AJAX, tu solo tendrias que crear el div que vasa regresar y modificar los datos de conexion yconsulta.

igual dale una leida al script.

Código Javascript:
Ver original
  1. /************Funciones de Ajax para el intercambio Asincrono de Información*************/
  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.           if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  14.               xmlhttp = new XMLHttpRequest();
  15.           }
  16.           return xmlhttp;
  17.       }
  18. /****************Realizacion de consulta por medio de AJAX al presional ENTER Keycode == 13********************/
  19.       function detectkey(evt,obj) {
  20.       keycode = (evt.keyCode==0) ? evt.which : evt.keyCode;
  21.      if (keycode==13){
  22.           /*Mi modificacion*/
  23.           if (document.getElementById('NumFolio').value.length == 0){
  24.           alert("Debe completar el formulario");
  25.           document.getElementById('NumFolio').focus();
  26.           return 0;}
  27.           /*Mi modificacion*/
  28.           folio=obj.value + String.fromCharCode(keycode);
  29.           pagina='externos/filtra.php?folio='+folio;
  30.           }
  31.           divcontenido = document.getElementById('SSform1');
  32.           ajax=objetoAjax();
  33.           ajax.open("POST", pagina, true);
  34.           ajax.onreadystatechange=function() {
  35.             if (ajax.readyState==4) {
  36.               divcontenido.innerHTML = ajax.responseText
  37.             }
  38.           }
  39.           ajax.send(null);
  40.       }