Foros del Web » Programando para Internet » Javascript » Frameworks JS »

validar Objeto XMLHttpRequest en IE6 o IE7

Estas en el tema de validar Objeto XMLHttpRequest en IE6 o IE7 en el foro de Frameworks JS en Foros del Web. Hola amigos que tal,aqui tengo un problema con un parte de un script q usa el objeto XMLHttpRequest ,se trta que en un select box ...
  #1 (permalink)  
Antiguo 06/10/2007, 15:45
 
Fecha de Ingreso: septiembre-2007
Mensajes: 44
Antigüedad: 16 años, 7 meses
Puntos: 0
validar Objeto XMLHttpRequest en IE6 o IE7

Hola amigos que tal,aqui tengo un problema con un parte de un script q usa el objeto XMLHttpRequest ,se trta que en un select box tengo 6 opciones y lo que quiero es que al elegir una de ellas se muestre otro select al lado derecho,esto lo hace en firefox pero en IE7 no como para validar esto???? aqui les paso parte del codigo.

------------------------------------Serodont.php--------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Servicio de Odontológia</title>
<!--<link href="../../Ccs/estilo.css" rel="stylesheet" type="text/css" background-image: url(../wamp/www/obe/Images/Titulos/Bane de OBE1.png);/>-->
<link rel="StyleSheet" href="estilos.css" type="text/css">
<script language="javascript" src="funciones.js"></script>
</head>

<body>


.
.
.
</tr>
<tr class="Estilo1">
<td class="CeldaColor3"><div align="left">Facultad:</div></td>
<td class="CeldaColor3">
<div align="left" id="fac">
<select name="Facultad" id="Facultad" onChange="mostrar(this)">
<option value="0">Seleccione</option>
<option value="1">FACULTADES / ESCUELA</option>
<option value="2">CIENCIAS/ ESCUELAS</option>
<option value="3">CIENCIAS JURIDICAS Y POLITICAS</option>
<option value="4">CIENCIAS ECONOMICAS Y SOCIALES</option>
<option value="5">FARMACIA</option>
<option value="6">HUMANIDADES Y EDUCACION</option>
<option value="7">INGENIERIA/ESCUELAS</option>
</select>
</div>
</td>
<td align="left"><div align="justify">Escuela:</div></td>
<td class="CeldaColor3">
<div align="left" id="esc">
<select name="escuela" id="escuela">
</select>
</div>
</td>
</tr>
.
.
.
----------------------------------------------------funciones.js-------------------------------------
var xhr;
function mostrar(x)
{


try {
// Internet Explorer 5.5+
xhr = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
// Internet Explorer 5.0+
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (ex) {
xhr = false;
}
}
if (!xhr && typeof XMLHttpRequest != 'undefined')
{
// Mozilla 1.0+ y Safari 1.2+
xhr = new XMLHttpRequest();
}


if (x.options[0].selected)
{
document.getElementById('Facultad');
document.getElementById('escuela').style.visibilit y="visible";

}
if (x.options[1].selected)
{
document.getElementById('Facultad');
document.getElementById('escuela');
xhr.onreadystatechange=xhrCompletado;
xhr.open("POST", "esc1.html");
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
xhr.send("name="+encodeURIComponent(x.options[1].selected.value));
}
if (x.options[2].selected)
{
document.getElementById('Facultad');
document.getElementById('escuela');
xhr.open("POST", "esc2.html");
xhr.onreadystatechange=xhrCompletado;
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
xhr.send("name="+encodeURIComponent(x.options[2].selected.value));
}
if (x.options[3].selected)
{
document.getElementById('Facultad');
document.getElementById('escuela');
xhr.open("POST", "esc3.html");
xhr.onreadystatechange=xhrCompletado;
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
xhr.send("name="+encodeURIComponent(x.options[3].selected.value));
}
if (x.options[4].selected)
{
document.getElementById('Facultad');
document.getElementById('escuela');
xhr.onreadystatechange=xhrCompletado;
xhr.open("POST", "esc4.html");
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
xhr.send("name="+encodeURIComponent(x.options[4].selected.value));
}
if (x.options[6].selected)
{
document.getElementById('Facultad');
document.getElementById('escuela');
xhr.onreadystatechange=xhrCompletado;
xhr.open("POST", "esc5.html");
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
xhr.send("name="+encodeURIComponent(x.options[6].selected.value));
}
if (x.options[7].selected)
{
document.getElementById('Facultad');
document.getElementById('escuela');
xhr.onreadystatechange=xhrCompletado;
xhr.open("POST", "esc6.html", true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;');
xhr.send("name="+encodeURIComponent(x.options[7].selected.value));
}
}

function xhrCompletado()
{
if (xhr.readyState == 4)
{
var d=document.getElementById('escuela');
d.innerHTML = xhr.responseText;
}
}
  #2 (permalink)  
Antiguo 06/10/2007, 22:55
Avatar de demiurgo_daemon  
Fecha de Ingreso: diciembre-2006
Ubicación: Querétaro
Mensajes: 184
Antigüedad: 17 años, 4 meses
Puntos: 2
Re: validar Objeto XMLHttpRequest en IE6 o IE7

Hola,

posiblemente tu problema esté en
Código:
if (x.options[0].selected)
Dudo que x.options[] sea uan variable estándar; yo usaría x.value (a partir de que cada <option> tiene definido un valor), para que lo de arriba quede
Código:
if (x.value=="0")
lo mismo para cada opción. Así también quedas libre en caso de que las opciones cambien de orden.

saludos
  #3 (permalink)  
Antiguo 08/10/2007, 06:44
 
Fecha de Ingreso: septiembre-2007
Mensajes: 44
Antigüedad: 16 años, 7 meses
Puntos: 0
Re: validar Objeto XMLHttpRequest en IE6 o IE7

si pero la validacion de las opciones seria : if(x.option.value= "0") o con eso que me pusieron ya es suficiente para validar cada opcion????? Gracias.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:00.