Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/02/2011, 13:41
Avatar de solrakmnk
solrakmnk
 
Fecha de Ingreso: febrero-2011
Ubicación: Mexico
Mensajes: 23
Antigüedad: 14 años, 1 mes
Puntos: 3
Respuesta: Coger variable del select (PHP)

pues es la primera ves que escribo aca y espero poder ayudarte, lo puedes hacer con ajax, yo lo hice con tres archivos.

index.php

Código PHP:
Ver original
  1. <html>
  2.     <head>
  3.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4.         <script languaje="javascript" src="ajax.js"></script>
  5.         <title></title>
  6.     </head>
  7.     <body>
  8.          <select name="marca" id="marca" style="width:148px;" onChange="actualiza(this.value)"><option value= "">Elija modelo</option><option value= "S911">Serie 911</option><option value="964"><option value="962">962</option><option value="968">968</option></select>
  9.     </body>
  10. </html>


Ajax.js

Código Javascript:
Ver original
  1. function objetoAjax(){
  2.     /* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
  3.     lo que se puede copiar tal como esta aqui */
  4.     var xmlhttp=false;
  5.     try
  6.     {
  7.         // Creacion del objeto AJAX para navegadores no IE
  8.         xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  9.     }
  10.     catch(e)
  11.     {
  12.         try
  13.         {
  14.             // Creacion del objet AJAX para IE
  15.             xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  16.         }
  17.         catch(E) { xmlhttp=false; }
  18.     }
  19.     if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); }
  20.  
  21.     return xmlhttp;
  22. }
  23.  
  24.  
  25. function actualiza(id){
  26.   ajax=objetoAjax();
  27.   ajax.open("POST", "consulta.php",true);
  28.   ajax.onreadystatechange=function() {
  29.   if (ajax.readyState==4) {
  30.   alert(ajax.responseText)
  31.   }
  32.   }
  33.   ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  34.   ajax.send("id="+id)
  35. }

consulta.php

Código PHP:
Ver original
  1. <?php
  2. echo "la consulta con: $_POST[id]";
  3. ?>