El problema es que el 2° select no carga.
Creo que el problema esta al usar esta instruccion: "getElementById", para hacer referencia al <select> me parece que tengo que usar otra, pero no estoy seguro, bueno GRACIAS.
Les dejo el codigo
Funciones de Ajax
Código:
function objetoAjax(){
var xmlhttp=false;
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 carga_mat(dato){
var divResultado=document.getElementById('destino');
var t4=document.getElementById('cod_dpto').value;
ajax=objetoAjax();
ajax.open("POST", dato);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divResultado.innerHTML = ajax.responseText;
}
}
ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("cod_dpto="+t4);
}
cargaparcial.php
Código:
<?php
@session_start();
include ("funciones.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Red</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<script type="text/javascript" language="javascript" src="js/funciones.js"></script>
</head>
<script type="text/javascript" src="js/jquery.js"></script>
<?php
if((isset($_SESSION['autorizado'])) AND ($_SESSION['autorizado']=TRUE)){
?>
<form name="frmcargarparcial" action="cargarparcial.php" method="POST">
<table>
<td><tr> Seleccione Departamento: <select id="cod_dpto" name="cod_dpto" onchange="carga_mat('p_cargas.php'); return false">
<?php
conectar();
$consulta="SELECT codigo_dpto_uba, detalle FROM dpto";
$rowset=mysql_query ($consulta);
if(mysql_num_rows($rowset)){
echo '<option value="-1">Selecciona un pais</option>';
while($row = mysql_fetch_array($rowset)){
//echo "<p>".$row['nom_us']." - ".$row['ape_us']." - ".$row['tipo_doc_us']." - ".$row['id_us']."</p> \n <br>";
echo '<OPTION VALUE="'.$row['codigo_dpto_uba'].'" >'.$row['detalle'].'</OPTION>'; //Con esto puedo lograr que se autocomplete el option value.
}
?>
</select></tr>
<tr><select id="destino" name="destino">
</select></tr>
</td>
<input type="submit" value="Enviar"/>
</table>
</form >
<?php
}
}else{
redirect ("index.php");
}
?>
p_cargas.php
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Red</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body>
<?php
@session_start();
include ("funciones.php");
reg ("entre a p_cargas.php", "STATUS", "p_cargas.php");
//echo '<scrip> alert ('.$_POST['cod_dpto'].')</scrip>'
reg ($_POST['cod_dpto'], "STATUS", "p_cargas.php");
echo '<option value="-1">Selecciona una Materia</option>';
$consulta="SELECT codigo_mat_uba, detalle_mat_uba FROM materias WHERE codigo_dpto_uba='{$_POST['cod_dpto']}'";
$rowset=mysql_query ($consulta);
reg ($rowset, "STATUS", "p_cargas.php");
if(mysql_num_rows($rowset)){
reg ("entre a p_cargas.php - WHILE", "STATUS", "p_cargas.php");
while($row = mysql_fetch_array($rowset)){
echo '<option value="'.$row['codigo_mat_uba'].'" >'.$row['detalle_mat_uba'].'</option>'; //Con esto puedo lograr que se autocomplete el option value.
}
}
?>
</body>
</html>


