<script type="text/javascript">
var peticion = false;
var testPasado = false;
try
{
peticion = new XMLHttpRequest();
}
catch (trymicrosoft)
{
try
{
peticion = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (othermicrosoft)
{
try
{
peticion = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed)
{
peticion = false;
}
}
}
if (!peticion)
alert("ERROR AL INICIALIZAR!");
function cargarCombo (url, comboAnterior, element_id)
{
//Obtenemos el contenido del div
//donde se cargaran los resultados
var element = document.getElementById(element_id);
//Obtenemos el valor seleccionado del combo anterior
var valordepende = document.getElementById(comboAnterior)
var x = valordepende.value
//construimos la url definitiva
//pasando como parametro el valor seleccionado
var fragment_url = url+'?Id_Facultad='+ x ;
//abrimos la url
peticion.open("GET", fragment_url);
peticion.onreadystatechange = function()
{
if (peticion.readyState == 4)
{
//escribimos la respuesta
element.innerHTML = peticion.responseText;
}
}
peticion.send(null);
}
</script>
<select name="facultad" onchange="javascript:cargarCombo('prueba.jsp', 'facultad', 'div_prueba')" id="facultad">
<option></option>
<%
if (!admin.isClosed())
{
ingreso = admin.createStatement();
valida = ingreso.executeQuery("select Id_Facultad, Nombre from simulador_ecaes.facultad" );
System.out.println(valida);
while (valida.next())
{
String idfac=valida.getString("Id_Facultad");
String nomfac=valida.getString("Nombre");
out.println("<option value='"+idfac+"'>"+idfac+","+nomfac+"</option>");
}
admin.close();
}
else
out.println("fallo");
%>
</select>
<div name="div_prueba"></div>