Ver Mensaje Individual
  #10 (permalink)  
Antiguo 21/10/2013, 08:06
Avatar de herzbazi
herzbazi
 
Fecha de Ingreso: febrero-2012
Mensajes: 612
Antigüedad: 12 años, 2 meses
Puntos: 36
Pregunta Respuesta: select dependientes

Código PHP:
Ver original
  1. <select name="found1" class="selectf" Id="select1">
  2.                             <?php
  3.                                 $found=mysql_query("select * from found");
  4.                                 while($found1=mysql_fetch_assoc($found))
  5.                                 {
  6.                                     $found2[]=$found1;
  7.                                 }
  8.                                 foreach ($found2 as $f){
  9.                             ?>
  10.                             <option name="Sustainable" value="<?php echo $f["id"] ?>"><?php echo $f["Sustainable"] ?></option>
  11.                             <?php
  12.                                 }
  13.  
  14.                             ?>
  15.                         </select>
  16.  
  17.  
  18.                         <select name="found2" class="selectf">
  19.                             <?php
  20.  
  21.                                 switch ($id){
  22.                                         case (2):
  23.                                                
  24.                                         $foundcargado=mysql_query("select * from found1");
  25.                                         while($foundcargado1=mysql_fetch_assoc($foundcargado))
  26.                                             {
  27.                                                 $foundcargado2[]=$foundcargado1;
  28.                                             }
  29.                                         foreach ($foundcargado2 as $fcargado2){
  30.                             ?>
  31.                             <option name="Sustainable" value="<?php echo $fcargado2["id"] ?>"><?php echo $fcargado2["Community_Change"] ?></option>
  32.                             <?php
  33.                                 }
  34.                                         break;
  35.                                         case (3):
  36.                                         $foundcargados=mysql_query("select * from found2");
  37.                                         while($foundcargados1=mysql_fetch_assoc($foundcargados))
  38.                                             {
  39.                                                 $foundcargados2[]=$foundcargados1;
  40.                                             }
  41.                                         foreach ($foundcargados2 as $fcargados2){
  42.                             ?>
  43.                             <option name="Sustainable" value="<?php echo $fcargados2["id"] ?>"><?php echo $fcargados2["selections"] ?></option>
  44.                             <?php
  45.                                 }
  46.                                         break;
  47.                                         case(4):
  48.                                         $f=mysql_query("select * from found3");
  49.                                         while($f1=mysql_fetch_assoc($f))
  50.                                             {
  51.                                                 $f2[]=$f1;
  52.                                             }
  53.                                         foreach ($f2 as $f){
  54.                             ?>
  55.                             <option name="Sustainable" value="<?php echo $f["id"] ?>"><?php echo $f["selections"] ?></option>
  56.                             <?php
  57.                                 }                                      
  58.                                         break;
  59.                                         case(5):
  60.                                                 $ff=mysql_query("select * from found4");
  61.                                         while($ff1=mysql_fetch_assoc($ff))
  62.                                             {
  63.                                                 $ff2[]=$ff1;
  64.                                             }
  65.                                         foreach ($ff2 as $ff){
  66.                             ?>
  67.                             <option name="Sustainable" value="<?php echo $ff["id"] ?>"><?php echo $ff["selections"] ?></option>
  68.                             <?php                                                                      
  69.                                 }
  70.                                }
  71.                             ?>
  72.                         </select>

ese es el codigo logicamente colocando manualmente el valor del foreach funciona correctamente lo que necesito es capturar el valor de value del option que imprime y asignarlo al switch

switch ($id)

se que es mediante ajax pero ahi quedo corto espero puedan ayudarme
__________________
Enseña todo lo que sepas...
Aprende todo lo que puedas..