Ver Mensaje Individual
  #24 (permalink)  
Antiguo 10/07/2012, 22:45
isabelramirezmontoya
 
Fecha de Ingreso: noviembre-2010
Mensajes: 204
Antigüedad: 13 años, 5 meses
Puntos: 1
Respuesta: Variables no pasan en etiqueta form

Cita:
Iniciado por rodrigo791 Ver Mensaje
Tenes un entrevero de código impresionante que no sabes ni lo que estas haciendo.
Trata de usar Highlight para mostrar tu codigo es bastante molesto tener que leerlo sin él, solo tenes que elegir el lenguaje en el select que dice "Highlight"
1 - decidite de una vez, LLAMAS A LA FUNCIÓN EN ONLOAD O CON EL BOTON?
supongamos que lo haces con el boton.No se para que le pasas como parametro el archivo php a la función si ya ella lo tiene dentro, en fin...


Código HTML:
Ver original
  1. <script type="text/javascript">
  2.  
  3. function objetoAjax(){
  4. var xmlhttp=false;
  5. try {
  6. xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  7. } catch (e) {
  8. try {
  9. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  10. } catch (E) {
  11. xmlhttp = false;
  12. }
  13. }
  14.  
  15. if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  16. xmlhttp = new XMLHttpRequest();
  17. }
  18. return xmlhttp;
  19. }
  20.  
  21.  
  22.  
  23. function MostrarConsulta(){
  24.  
  25. var divResultado = document.getElementById('resultadoDeLaRespuesta');
  26.  
  27. var t1 = document.getElementById("categoria").value;
  28.  
  29. var t2 = document.getElementById("orden").value;
  30.  
  31. ajax=objetoAjax();
  32. ajax.open("GET", "filtroconsulta.php?t1="+t1+"&t2="+t2,true);
  33. ajax.onreadystatechange=function() {
  34. if (ajax.readyState==4) {
  35. var abc = ajax.responseText;
  36. divResultado1.innerHTML = abc;
  37.  
  38. }
  39. }
  40. ajax.send(null)
  41. }
  42.  
  43. </head>
  44. <form method="get" name="frm" action="" onsubmit="MostrarConsulta();">
  45. <div class="filtro1">Categoria: <select name="categoria" id="categoria">
  46. <option value="opcion1">opcion1
  47. <option value="opcion2">opcion2
  48. <option value="opcion3" selected>opcion3
  49. </div>
  50.  
  51. <div class="filtro2">Informacion: <select name="orden" id="orden">
  52. <option value="opcion1">opcion1
  53. <option value="opcion2">opcion2
  54. <option value="opcion3" selected>opcion3
  55. </div>
  56. <input type="submit" value="Aplicar Filtro">
  57. </form>
  58.  
  59. <div id="resultadoDeLaRespuesta"></div>
  60. </body>

tu php:
Código PHP:
Ver original
  1. <?
  2. $categoria = $_GET['t1'];
  3. $orden = $_GET['t2'];
  4.  
  5. echo $categoria;
  6. echo "<br />";
  7. echo $orden;
  8. ?>

A ver como te va con eso
rodrigo791, gracias por tu tiempo y paciencia

Que pena contigo, la verdad soy nueva en esto y apenas estoy aprendiendo .

El ejemplo que me colocaste lo copie tal cual lo colocaste en el ejemplo, pero cuando lo ejecuto noto en la URL las variables si pasan, pero en el php que me colocaste

Código PHP:
Ver original
  1. <?
  2. $categoria = $_GET['t1'];
  3. $orden = $_GET['t2'];
  4.  
  5. echo $categoria;
  6. echo "<br />";
  7. echo $orden;
  8. ?>

no me muestra nada



Isabel