Ver Mensaje Individual
  #2 (permalink)  
Antiguo 16/10/2010, 05:37
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: actualizar select al salir de otro select

Hay varias maneras de hacerlo. Te dejo un ejemplo en php (con array, pero no te será complejo generar el array con una consulta a tu base de datos) para que lo adaptes al lenguaje de servidor que uses (podés testearlo acá: http://www.disegnocentell.com.ar/new...onados_rpc.php):
Código PHP:
<?php
if(isset($_GET['p'])){
    switch(
$_GET['sel']){
        case 
'1':
            
$ret=array('Final del Juego','Rayuela','El Señor de loas Anillos');
            break;
        case 
'2':
            
$ret=array('rock','new age');
            break;
        case 
'3':
            
$ret=array('español','php','javascript');
            break;
        default:
            echo 
'document.getElementById("pp").innerHTML="<select name=\"dos\" id=\"dos\"></select>";';
            exit;
    }
$html='<select name=\"dos\" id=\"dos\">';
foreach(
$ret as $v)
    
$html.='<option value=\"'.$v.'\">'.$v.'</option>';
$html.='</select>';
echo 
'document.getElementById("pp").innerHTML="'.$html.'";';
exit;
}
?>
<!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=iso-8859-1" />
<title>test</title>
<script>
function adjs(url){
    oldsc=document.getElementById("old_sc");
       if(oldsc)
            document.getElementsByTagName('body')[0].removeChild(oldsc);
    sc=document.createElement('script');
    sc.id="old_sc";
    sc.src=url+'&'+Math.random();
    document.getElementsByTagName('body')[0].appendChild(sc);
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
      <select name="uno" id="uno" onchange="adjs('?p&sel='+this.value)">
      <option value="0">seleccionar</option>
      <option value="1">libros</option>
    <option value="2">música</option>
    <option value="3">lenguaje</option>
  </select>
  <div id="pp"><select name="dos" id="dos">
  </select></div>
</form>
</body>
</html>