Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/10/2013, 08:13
placks73
 
Fecha de Ingreso: mayo-2011
Mensajes: 15
Antigüedad: 13 años
Puntos: 0
Capturar dato

Alguien que me pueda ayudar con este codigo?

Tengo una suma de 3 campos con una funcion en javascript el resultado se carga en un ultimo campo con onchange, todos los campos los capturo en unas variables con PHP pero no he logrado capturar el del resultado que esta en onchage, este es el codigo:

<html>...
<head>
<script>
function suma() {

valor1 = document.getElementById("A").value;
valor2 = document.getElementById("B").value;
valor3 = document.getElementById("C").value;
total = parseFloat(valor1) + parseFloat(valor2) + parseFloat(valor3);

document.getElementById("total").value= total;
}
</script>


</head>

<body>
<form action="resultsuma.php" method="post">


<input type="text" value="" name="var1" id="A" onchange="suma();">
<input type="text" value="" name="var2" id="B" onchange="suma();">
<input type="text" value="" name="var3" id="C" onchange="suma();">
<input type="text" value="" name="form" id="total" value="0" disabled onchange="suma();">

<input type="submit" value="Guardar">

</body>
</html>

<?php

$variable1 = $_POST['var1'];
echo $variable1;
$variable2 = $_POST['var2'];
echo $variable2;
$variable3 = $_POST['var3'];
echo $variable3;
$resultado = $_GET['total'];
echo $resultado;
?>