I am trying to make a sum with decimals, I am starting to use javascript
to make operations etc.
this is the script I use:
<script>
function sumar (valor) {
var total = 0;
valor = parseInt(valor); // Convertir el valor a un entero (número).
total = document.getElementById('spTotal').innerHTML;
// Aquí valido si hay un valor previo, si no hay datos, le pongo un cero "0".
total = (total == null || total == undefined || total == "") ? 0 : total;
/* Esta es la suma. */
total = (parseInt(total) + parseInt(valor));
// Colocar el resultado de la suma en el control "span".
document.getElementById('spTotal').innerHTML = total;
}
</script>
How can I use that code to do them with decimals and not just with integers?