Hola (ya se que es viejo el post) , haber si me podeis ayudar... He ido siguiendo los pasos de los ficheros que pusistes y no me funciona. Soy un negado en javascript.
PD:Son para un componente joomla.
default.php
Cita: <html>
<head>
<script language="JavaScript" type="text/javascript" src="ajax.js"></script>
</head>
<body>
<form name="f1" method="post">
<?php
$database=mysql_query("SELECT * FROM jos_area" );
if ($fila = mysql_fetch_array($database)){
echo '<select name="id_area" onChange="optionArea();">';
echo '<option value="0" SELECTED>Choose One </option>';
do {
echo '<option value= "'.$fila["id_area"].'">'.$fila["area"].'</option>';
} while ($fila = mysql_fetch_array($database));
echo '</select>';
}
?>
<div id="combotema"><select><option>[ Seleccione ]</option></select></div>
</form>
</body>
</html>
ajax.js
Cita: 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 optionArea(){
divResultado = document.getElementById('combotema');
/*divResultado = dijit.byId('combotema');*/
id=document.f1.id_area.value;
ajax=objetoAjax();
ajax.open("POST", "combotema.php",true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divResultado.innerHTML = ajax.responseText
}
}
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.send("id="+id)
}
combotema.php
Cita: <?php
$database=mysql_query("SELECT * FROM jos_tema WHERE id_area =". $_POST['id'] );
if ($fila = mysql_fetch_array($database)){
echo '<select name= "id_tema">';
echo '<option value="0" SELECTED>Choose One </option>';
do {
echo '<option value= "'.$fila["id_tema"].'">'.$fila["tema"].'</option>';
} while ($fila = mysql_fetch_array($database));
echo '</select>';
}
?>
A alguien se le ocurre pk no funciona? creo que ni accede al js :S
Lo unico que va son los accesos a la BD
Gracias!