Ver Mensaje Individual
  #7 (permalink)  
Antiguo 27/03/2013, 01:49
edodani
 
Fecha de Ingreso: marzo-2013
Ubicación: Valencia
Mensajes: 29
Antigüedad: 11 años, 1 mes
Puntos: 3
De acuerdo Respuesta: Problemas con envío de números (php y AJAX)

Solucionado. También me funciona poniendo el script al final (para que cargue toda la página). Eso sí, con getElementsByTagName no, aunque debería...

Código HTML:
Ver original
  1. <!DOCTYPE html>
  2.     <head>
  3.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  4.         <title>php while</title>
  5.     </head>
  6.     <body>
  7.         <form method="GET" action="php_while.php">
  8.             Inserta el número del que quieres que escriba la tabla de multiplicar:
  9.             <br/><input type="text" name="i" id="i"/>
  10.             <br/><button type="button" onclick="enviar()">OK</button>
  11.             <div id="tabla"></div>
  12.         </form>
  13.         <script type="text/javascript">
  14.         function enviar(){
  15.             var xmlhttp = new XMLHttpRequest();
  16.             xmlhttp.onreadystatechange=function(){
  17.                 if (xmlhttp.readyState==4 && xmlhttp.status==200){
  18.                     document.getElementById("tabla").innerHTML=xmlhttp.responseText;
  19.                 }
  20.             }
  21.             var valor = document.getElementById("i").value;
  22.             xmlhttp.open("GET","./php_while.php?i="+valor,true);
  23.             xmlhttp.send();
  24.             }
  25.         </script>
  26.     </body>
  27. </html>