Hola, la verdad no entiendo muy bien lo que quieres hacer, si pudieras explicar mejor o comentar el código. Te recomiendo que lo ordenes un poco, asi quizas veas mejor que es lo que esta mal, ya que lo estuve leyendo y en algunos lugares habia errores de sintaxis, aqui trate de ordenarlo un poco, hechale un vistazo:
Código PHP:
Ver original
<!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=utf-8" />
<title>Listas Dinámicas</title>
<script type="text/javascript" charset="utf-8">
/**
* Lo que hace esta funcion
*
* @param <type> xPro Sobre el parametro
*/
function componerLista(xPro)
{
document.forms.frmDatos.selDepartamento.disabled = true;
document.forms.frmDatos.selMunicipios.length = 0;
cargarMunicipios(xPro);
document.forms.frmDatos.selDepartamento.disabled = false;
}
/**
* Lo que hace esta función
*
* @param <type> xCiu Sobre el parametro
*/
function cargarMunicipios(xCiu) {
var o;
document.forms.frmDatos.selMunicipios.disabled=true;
<?php $tablaMunicipios = mysql_query('SELECT * FROM municipio ORDER BY mun_nombre ASC');?> if (xCiu == <?php echo $registroMunicipios["mun_id_departamento"]; ?>)
{
o = document.createElement("OPTION");
o.text = '<?php echo $registroMunicipios["mun_nombre"]; ?>';
o.value = <?php echo $registroMunicipios["id_municipio"]; ?>;
document.forms.frmDatos.selMunicipios.options.add (o);
}
<?php endwhile; ?>
document.forms.frmDatos.selMunicipios.disabled=false;
}
</script>
</head>
<body>
<form id="frmDatos" name="frmDatos" method="post" action="">
<label>Departamento:</label>
<select name="selDepartamento" size="6" id="selDepartamento" onchange="componerLista(document.forms.frmDatos.selDepartamento[selectedIndex].value);">
<?php $tablaDepartamento = mysql_query('SELECT * FROM departamento ORDER BY dep_nombre ASC');?> <?php printf('<option value="%s">%s</option>', $registroDepartamento['id_departamento'], $registroDepartamento['dep_nombre']);?>
<?php endwhile;?>
</select>
<label>Municipio:</label>
<select name="selMunicipios" size="6" id="selMunicipios">
<?php $tablaDepartamento = mysql_query('SELECT * FROM departamento ORDER BY dep_nombre ASC');?> <?php printf('<option value="%s">%s</option>', $registroDepartamento['id_departamento'], $registroDepartamento['dep_nombre']);?>
<?php endwhile;?>
</select>
</form>
</body>
</html>