Ver Mensaje Individual
  #5 (permalink)  
Antiguo 06/02/2014, 11:03
Avatar de alexisverano
alexisverano
 
Fecha de Ingreso: septiembre-2008
Ubicación: La Habana.Cuba
Mensajes: 298
Antigüedad: 15 años, 6 meses
Puntos: 36
Respuesta: [APORTE] - Select dependiente (3 niveles)

FINALMENTE:

ajax.js

Código Javascript:
Ver original
  1. //========================
  2. //CREACION DEL OBJETO AJAX
  3. //========================
  4. function objetoAjax(){
  5.     var xmlhttp=false;
  6.     try {
  7.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  8.     } catch (e) {
  9.         try {
  10.            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  11.         } catch (E) {
  12.             xmlhttp = false;
  13.         }
  14.     }
  15.  
  16.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  17.         xmlhttp = new XMLHttpRequest();
  18.     }
  19.     return xmlhttp;
  20. }
  21.  
  22. //==================
  23. function mostrarMunicipios(){
  24.  
  25.     divResultado = document.getElementById('listamunicipios');
  26.     prov=document.getElementById('obj_provincia').value;
  27.  
  28.     ajax=objetoAjax();
  29.     ajax.open("POST", "municipios.php");
  30.     ajax.onreadystatechange=function() {
  31.         if (ajax.readyState==4) {
  32.             divResultado.innerHTML = ajax.responseText
  33.         }
  34.     }
  35.     ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  36.     ajax.send("idprov="+prov)
  37. }
  38.  
  39.  
  40. //==================
  41. function mostrarConsejos(){
  42.  
  43.     divResultado = document.getElementById('listaconsejos');
  44.     mun=document.getElementById('obj_municipio').value;
  45.  
  46.     ajax=objetoAjax();
  47.     ajax.open("POST", "consejos.php");
  48.     ajax.onreadystatechange=function() {
  49.         if (ajax.readyState==4) {
  50.             divResultado.innerHTML = ajax.responseText
  51.         }
  52.     }
  53.     ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  54.     ajax.send("idmun="+mun)
  55. }