Foros del Web » Programando para Internet » Jquery »

Selects Dependientes en una sola tabla con jquery

Estas en el tema de Selects Dependientes en una sola tabla con jquery en el foro de Jquery en Foros del Web. Hola buenas tardes me gustaria saber si me podrian ayudar con unos selects dependientes de una sola tabla mi tabla se llama vehiculo con los ...
  #1 (permalink)  
Antiguo 10/04/2013, 13:13
Avatar de Ilidam  
Fecha de Ingreso: julio-2009
Ubicación: Veracruz
Mensajes: 108
Antigüedad: 14 años, 8 meses
Puntos: 0
Pregunta Selects Dependientes en una sola tabla con jquery

Hola buenas tardes me gustaria saber si me podrian ayudar con unos selects dependientes de una sola tabla mi tabla se llama vehiculo con los campos marca,modelo,año,motor asta ahora lo tengo asi --->
Código HTML:
Ver original
  1. <?php error_reporting(E_ERROR); ?>
  2. <?
  3. require('config.php');
  4. require('include/conexion.php');
  5. ?>
  6. <title>BUSQUEDA</title>
  7. <style type="text/css">
  8.  
  9. html {  background-image: url(images/glowcolor.png); }
  10. #Layer3 {
  11.     background-color: rgba(54, 206, 240, 0.5);
  12. -moz-border-radius: 1em;
  13. -webkit-border-radius: 1em;
  14. border-radius: 1em;
  15.  
  16.         background-position: center;
  17.     width:600px;
  18.  
  19.  
  20. }
  21.  
  22. <script language="javascript">
  23.     function myChangeHandler() {
  24.         this.options[this.selectedIndex].value;
  25.         this.form.submit();
  26. }
  27. <div id="Layer3">
  28.  
  29.  
  30.              <form id="1" name="1" method="post" action="2.php">
  31.        <fieldset><legend><h2><font face="calibri" color="#FFFFFF">APLICACION POR VEHICULOS</font> </h2></legend>
  32.            <br>
  33.  
  34.       <?php
  35.   $sql = "Select DISTINCT marca from vehiculo order by marca";
  36.   $result = mysql_query( $sql);
  37. ?>
  38.         <font face="calibri" color="#FFFFFF">&nbsp; MARCA </font> <select name="marca" id="marca" onchange="myChangeHandler.apply(this)">
  39.           <option>------------------SELECCIONA------------------</option>
  40. <?php    while ( $row = mysql_fetch_array($result) ) {?>
  41.     <option> <?php echo $row[0];?>  </option>
  42.         <?php } ?>
  43. <br><br>
  44.   </fieldset> </form> </div>
  45.  
  46.  
  47.  
  48.  
  49. .....en el segundo archivo   2.php
  50.  
  51. <?php error_reporting(E_ERROR); ?>
  52. <?
  53. require('config.php');
  54. require('include/conexion.php');
  55. ?>
  56. <title>BUSQUEDA</title>
  57. <style type="text/css">
  58.  
  59. html {  background-image: url(images/glowcolor.png); }
  60. #Layer3 {
  61.     background-color: rgba(54, 206, 240, 0.5);
  62. -moz-border-radius: 1em;
  63. -webkit-border-radius: 1em;
  64. border-radius: 1em;
  65.  
  66.         background-position: center;
  67.     width:600px;
  68.  
  69.  
  70. }
  71.  
  72. <script language="javascript">
  73.     function myChangeHandler() {
  74.         this.options[this.selectedIndex].value;
  75.         this.form.submit();
  76. }
  77.  
  78. <div id="Layer3">
  79.  
  80.     <form id="1" name="1" method="post" action="3.php">
  81.       <fieldset><legend><h2><font face="calibri" color="#FFFFFF">APLICACION POR VEHICULOS</font> </h2></legend>
  82.            <br>
  83.  
  84. <div id="marca">
  85.  
  86.  
  87.  <?php
  88. $marca=$_POST['marca'];
  89.  ?>
  90.          <font face="calibri" color="#FFFFFF">&nbsp;&nbsp; MARCA </font> <select name="marca" id="marca">
  91.            <option><? echo $marca; ?></option>
  92.           <option>------------------SELECCIONA------------------</option>
  93.  
  94.          </div>
  95.  
  96. <br>
  97.  
  98. <div id="modelo">
  99.           <?php
  100.          $modelo=$_POST['marca'];
  101.          $sql = "Select DISTINCT vehiculo.modelo from vehiculo where marca='$modelo' order by modelo";
  102.   $result = mysql_query( $sql);
  103. ?>
  104.          <font face="calibri" color="#FFFFFF">&nbsp;MODELO </font> <select name="modelo" onchange="myChangeHandler.apply(this)">
  105.           <option>------------------SELECCIONA------------------</option>
  106. <?php    while ( $row = mysql_fetch_array($result) ) {?>
  107.     <option> <?php echo $row[0];?>  </option>
  108.         <?php } ?>
  109.    </div>
  110.         <br><br>
  111.  
  112.  
  113.   </fieldset> </form> </div>

el detalle aki eske si kiero consultar nuevamente tengo k empezar desde marca y lo que k realmente necesito es que pueda ir intercalando la buskeda k me pueda regresar a modelo y se cargue automaticamnte el año y motor o si me regreso al año se cambien los motores etc...y asi sucesivamente de acuerdo al select k requiera... esa forma funciona bien aunque con jquery o ajax se veria mucho mejor o alguien tiene una mejor sugerencia

quiero hacer algo igual a esto solo k esta en aspx y yo estoy con php
http://www.standardbrand.com/online%20catalogs-ecatalog/content.aspx

Última edición por Ilidam; 10/04/2013 a las 15:06

Etiquetas: dependientes, selects, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:27.