tengo un problema con un codigo en java script que no puedo hacer
El codigo suma solo numeros enteros pero quisiera tambien que sume decimales
le cambie a parseFloat pero no funciona
ayuda x fa......
Aqui sta el codigo
Código PHP:
<html>
<head>
</head>
<script type="text/javascript">
function sumar(c){
var subtotal = 0;
campo = c.form;
if(!/^d*$/.test(c.value)) return;
for (var i = 0; i < campo.length-1; i++) {
if (!/^d+$/.test(campo[i].value)) continue;
subtotal += parseInt(campo[i].value);
}
document.getElementById('res').value = subtotal;
}
</script>
<body>
<form name="b" action="" method="post">
1:<input type="text" name="sum[]" value="0" onKeyUp="sumar(this);" /><br />
2:<input type="text" name="sum[]" value="0" onKeyUp="sumar(this);" /><br />
3:<input type="text" name="sum[]" value="0" onKeyUp="sumar(this);" /><br />
4:<input type="text" name="sum[]" value="0" onKeyUp="sumar(this);" /><br />
5:<input type="text" name="sum[]" value="0" onKeyUp="sumar(this);" /><br />
6:<input type="text" name="sum[]" value="0" onKeyUp="sumar(this);" /><br />
Resultado:<input type="text" id="res" value="0" />
</form>
</body>
</html>
porfa ayudaaaa
muchas gracias por su tiempo