Ver Mensaje Individual
  #4 (permalink)  
Antiguo 31/05/2010, 18:20
Avatar de dual3nigma
dual3nigma
Colaborador
 
Fecha de Ingreso: febrero-2010
Ubicación: Ciudad de México
Mensajes: 295
Antigüedad: 14 años, 2 meses
Puntos: 122
Respuesta: Listas encadenada

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
  1. <?php $conexion = mysql_connect('localhost', 'root', '');?>
  2. <?php mysql_set_charset('utf8', $conexion)?>
  3. <?php mysql_select_db('registro', $conexion);?>
  4.  
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7.     <head>
  8.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9.  
  10.         <title>Listas Dinámicas</title>
  11.  
  12.         <script type="text/javascript" charset="utf-8">
  13.         /**
  14.          * Lo que hace esta funcion
  15.          *
  16.          * @param <type> xPro   Sobre el parametro
  17.          */
  18.         function componerLista(xPro)
  19.         {
  20.             document.forms.frmDatos.selDepartamento.disabled = true;
  21.             document.forms.frmDatos.selMunicipios.length     = 0;
  22.             cargarMunicipios(xPro);
  23.             document.forms.frmDatos.selDepartamento.disabled = false;
  24.         }
  25.  
  26.         /**
  27.          * Lo que hace esta función
  28.          *
  29.          * @param <type> xCiu   Sobre el parametro
  30.          */
  31.         function cargarMunicipios(xCiu) {
  32.             var o;
  33.             document.forms.frmDatos.selMunicipios.disabled=true;
  34.             <?php $tablaMunicipios = mysql_query('SELECT * FROM municipio ORDER BY mun_nombre ASC');?>
  35.             <?php while ($registroMunicipios = mysql_fetch_array($tablaMunicipios)):?>
  36.                 if (xCiu == <?php echo $registroMunicipios["mun_id_departamento"]; ?>)
  37.                 {
  38.                     o = document.createElement("OPTION");
  39.                     o.text = '<?php echo $registroMunicipios["mun_nombre"]; ?>';
  40.                     o.value = <?php echo $registroMunicipios["id_municipio"]; ?>;
  41.                     document.forms.frmDatos.selMunicipios.options.add (o);
  42.                  }
  43.             <?php endwhile; ?>
  44.             <?php mysql_free_result($tablaMunicipios);?>
  45.  
  46.             document.forms.frmDatos.selMunicipios.disabled=false;
  47.         }
  48.        
  49.         </script>
  50.     </head>
  51.  
  52.     <body>
  53.         <form id="frmDatos" name="frmDatos" method="post" action="">
  54.             <label>Departamento:</label>
  55.             <select name="selDepartamento" size="6" id="selDepartamento" onchange="componerLista(document.forms.frmDatos.selDepartamento[selectedIndex].value);">
  56.                 <?php $tablaDepartamento = mysql_query('SELECT * FROM departamento ORDER BY dep_nombre ASC');?>
  57.                 <?php while ($registroDepartamento = mysql_fetch_array($tablaDepartamento)):?>
  58.                     <?php printf('<option value="%s">%s</option>',
  59.                             $registroDepartamento['id_departamento'], $registroDepartamento['dep_nombre']);?>
  60.                 <?php endwhile;?>
  61.                 <?php mysql_free_result($tablaDepartamento);?>
  62.             </select>
  63.            
  64.             <label>Municipio:</label>
  65.             <select name="selMunicipios" size="6" id="selMunicipios">
  66.                 <?php $tablaDepartamento = mysql_query('SELECT * FROM departamento ORDER BY dep_nombre ASC');?>
  67.                 <?php while ($registroDepartamento = mysql_fetch_array($tablaDepartamento)):?>
  68.                     <?php printf('<option value="%s">%s</option>',
  69.                             $registroDepartamento['id_departamento'], $registroDepartamento['dep_nombre']);?>
  70.                 <?php endwhile;?>
  71.                 <?php mysql_free_result($tablaDepartamento);?>
  72.             </select>
  73.         </form>
  74.     </body>
  75. </html>
  76. <?php mysql_close($conexion); ?>