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

Perdón!!! Las prisas, los nervios...

El html:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>php while</title>
<script type="text/javascript">
function enviar(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("tabla").innerHTML=xmlhttp .responseText;
}
}
var valor = document.getElementsByTagName("i").value;
xmlhttp.open("GET","./php_while.php?i="+valor,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form method="GET" action="php_while.php">
Inserta el número del que quieres que escriba la tabla de multiplicar:
<br/><input type="text" name="i"/>
<br/><button type="button" onclick="enviar()">OK</button>
<div id="tabla"></div>
</form>
</body>
</html>

El php:

<?php
error_reporting(0);
$i = $_GET['i'];
$x = 1;
echo "<table border='2px solid black';>";
while ($x <= 10){
echo '<tr><td>'.$i.'</td><td> X </td><td>'.$x.'</td><td> = </td><td>'.($i*$x).'</td>';
$x++;
}
echo "</table>";
?>