Ver Mensaje Individual
  #15 (permalink)  
Antiguo 24/04/2009, 11:53
dark_monk9
 
Fecha de Ingreso: mayo-2007
Mensajes: 41
Antigüedad: 17 años
Puntos: 0
Respuesta: Enviar valor seleccionado de un menu lista al codigo de otro

Ya funciono usando AJAX, ahora el problema es que funciona solo en Internet Explorer, en FireFox no funciona, el FF es version 3.0.9. ya mire en google y he cambiado miles de veces la forma en que se hace la conexion pero no he logrado que funcione.

Este es el codigo:


function NuevoAjax(){
var xmlhttp=true;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(E){
xmlhttp = false;
}
}

if(!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}

function Cargar(url){

var resultado='';

ajax=NuevoAjax();
ajax.open("GET", url,true);



ajax.onreadystatechange=function()
{
if(ajax.readyState==1)
{
// aqui va el preload si se requiere...";
}
else if(ajax.readyState==4)
{
if(ajax.status==200)
{
resultado=unescape(ajax.responseText);
}
else
{
resultado="Error:".ajax.status;
}
}
}

ajax.send(null);
return resultado;

}



function CargarMunicipios(estado,cmb_a_Cargar,seleccionado, divNombre)
{

var contenido,total,seleccionar=0,Lista;



var ComboList = document.getElementById(cmb_a_Cargar);
var divMunicipios=document.getElementById(divNombre);



Cargar("municipios.php?edo="+estado);
divMunicipios.innerHTML=Cargar("municipios.php?edo ="+estado);

Lista = document.getElementById('lista');



ComboList.innerHTML="";



if (Lista!=null)
{
Nodo = Lista.firstChild;
}


try
{
total=Lista.childNodes.length;
}
catch(E)
{
total=0;
}


for (i=1;i<=(total);i++)
{
id del Nodo
ComboList.options[i]=new Option(unescape(Nodo.innerText),Nodo.id);


if (Nodo.id==seleccionado)
{
seleccionar=i-1;
}

Nodo=Nodo.nextSibling;
}


if (total>0)
{
//Borrar el elemento en blanco que se inserta al inicio
ComboList.options[0]=null;

//Posicionarse en la opcion seleccionada
ComboList.options[seleccionar].selected="selected";
}


}

Última edición por dark_monk9; 24/04/2009 a las 12:01