Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/02/2011, 07:21
gabymar
 
Fecha de Ingreso: agosto-2008
Mensajes: 94
Antigüedad: 15 años, 8 meses
Puntos: 0
combox list enlazados

Hola estoy trabajando con una base de datos en mysql, en mi formulario deseo colocar dos combox list enlazados uno para cada tabla, donde el segundo combo muestre la informacion dependiendo de lo que selecciono el usuario en el primer combo, ya que es mucha informacion en las tablas no puedo colocar en el codigo la opciones. He investigado y se puede trabajar con java pero en los ejemplos colocan las opciones en el codigo y funcionan pero cuando lo adapto a lo que necestio no me funciona; adjunto el codigo que cambiado a mi necesidad. gracias por su ayuda.
Código PHP:

<html>
 <head>
  <title>
   FAQ-1: Selects
  </title>
  <script language="JavaScript">

   function addOpt(oCntrl, iPos, sTxt, sVal){
     var selOpcion=new Option(sTxt, sVal);
     eval(oCntrl.options[iPos]=selOpcion);
   }

   function cambia(oCntrl){
    while (oCntrl.length) oCntrl.remove(0);
    switch (document.frm.central.selectedIndex){
       <?php
                 
include("conexion.php"); 
                 
$conexion obtenerConexion(); 
                 
$result1=mysql_query("select CONCAT(C4, '/ ',cSerial,'/',cRangoI,'/', cRangoF) AS Completo from tnumeracion ");
                 if (
$row1 mysql_fetch_array($result1,$conexion)){ 
                 echo 
'<select name= "central">';
                 do {
                 echo 
'<option value= "'.$row1["Completo"].'">'.$row1["Completo"].'</option>';
                 } while (
$row1 mysql_fetch_array($result1)); 
                 echo 
'</select>';
                 }
                 
?> 
      break;

    }
   }
  </script>
 </head>
 <body>
  <form name="frm">
   <table border="0">
    <tr>
     <td>
      Central
     </td>
     <td>
              <?php
                   $conexion 
obtenerConexion(); 
                 
$result=mysql_query("select CONCAT(C4, '/ ',CENTRAL,'/',NUMCPA) AS nombre from tmatrizcpa ORDER BY CENTRAL DESC");
                 if (
$row mysql_fetch_array($result,$conexion)){ 
                 echo 
'<select name= "central" onchange="cambia(document.frm.numeracion)">';
                 do {
                 echo 
'<option value= "'.$row["nombre"].'">'.$row["nombre"].'</option>';
                 } while (
$row mysql_fetch_array($result)); 
                 echo 
'</select>';
                 }
                 
?> 
     </td>
     <td>
      &nbsp;
     </td>
     <td>
      Numeracion
     </td>
     <td>
       <?php
               
                 $conexion 
obtenerConexion(); 
                 
$result1=mysql_query("select CONCAT(C4, '/',cSerial,'/',cRangoI,'/', cRangoF) AS Completo from tnumeracion");
                 if (
$row1 mysql_fetch_array($result1,$conexion)){ 
                 echo 
'<select name= "numeracion">';
                 do {
                 echo 
'<option value= "'.$row1["Completo"].'">'.$row1["Completo"].'</option>';
                 } while (
$row1 mysql_fetch_array($result1)); 
                 echo 
'</select>';
                 }
                 
?> 
     </td>
    </tr>
   </table>
  </form>
 </body>
</html>