Ver Mensaje Individual
  #13 (permalink)  
Antiguo 22/10/2013, 09:37
nksn
 
Fecha de Ingreso: mayo-2009
Ubicación: Japon
Mensajes: 60
Antigüedad: 15 años
Puntos: 12
Respuesta: Capturar dato

realiza la suma del lado del servidor

$total = (float)$variable1 + (float)$variable2 + (float)$variable3;

o si tienes que obligatoria-mente hacer todo en js

Código PHP:
<script type="text/javascript"

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").valuetotal
    
document.getElementById("form").valuetotal


</script> 


</head> 

<body> 
    <form action="test.php" method="post" enctype="multipart/form-data"> 
        <input type="hidden" name="form" id="form" />
        <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="0" id="total" disabled /> /* en nombre de la variable es form */ 
        <input type="submit" value="Guardar"> 
    </form> 
</body>  
</html>