Agradezco de antemano a quien pueda echarle un vistazo y darme una mano.
Recién voy por el primer capítulo del libro de ajax que compré y no entiendo un pomo.
ahí va el códigp
Código:
<?php
require('xajax/xajax_core/xajax.inc.php');
$xajax = new xajax();
$xajax->setCharEncoding('ISO-8859-1');
$xajax->configure('decodeUTF8Input',true);
$host = "localhost";
$user= "";
$pass = "";
$base = "";
$conexion = mysql_connect ($host, $user, $pass);
mysql_select_db ($base, $conexion);
function motor()
{
$consulta = mysql_query ("SELECT marca from marcas order by marca asc");
?>
<select name='motor' id='motor' onChange="xajax_generar_select(document.formulario.motor.options[document.formulario.motor.selectedIndex].value)">";
<option value='0'>Elige</option>
<?
while($registro=mysql_fetch_row($consulta))
{ echo "<option value='".$registro[0]."'>".$registro[0]."</option>"; }
?> </select>
<?
}
function select_combinado($id_motor){
$consulta_mod=mysql_query("SELECT distinct modelo from vehiculos where marca='$id_motor'");
$nuevo_select = "<select name='modelos'>";
$nuevo_select .= '<option value="'. 0 .'">'.Elige.'</option>';
while($registro_mod=mysql_fetch_row($consulta_mod)){
$nuevo_select .= '<option value="' . $registro_mod[0] . '">' . $registro_mod[0] . '</option>';
}
$nuevo_select .= "</select>";
return $nuevo_select;
}
function generar_select($cod_motor){
$respuesta = new xajaxResponse();
if ($cod_motor==0){
$nuevo_select = '<select name="modelos">
<option value=0>Elige Modelo</option>
</select>
';
}else{
$nuevo_select = select_combinado($cod_motor);
}
$respuesta->assign("seleccombinado","innerHTML",$nuevo_select);
return $respuesta;
}
$xajax->registerFunction("generar_select");
$xajax->processRequest();
?>
<html>
<head>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1">
<title>Select Dimamicos con XAJAX</title>
<?
//En el <head> indicamos al objeto xajax se encargue de generar el javascript necesario
$xajax->printJavascript("xajax/");
?>
</head>
<body>
<form name="formulario">
Motor:
<br>
<? motor(); ?>
<br>
<br>
Modelos: <div id="seleccombinado">
<select name="modelos">
<option value=0>Elegir motor</option>
</select>
</div>
</form>
</body>
</html>


