Ver Mensaje Individual
  #6 (permalink)  
Antiguo 05/07/2011, 01:55
Avatar de ceSharp
ceSharp
 
Fecha de Ingreso: octubre-2008
Ubicación: Madrid
Mensajes: 495
Antigüedad: 15 años, 6 meses
Puntos: 66
Respuesta: suma y resta de una cantidad ya guardada en la bd

aquí lo tienes,
-------------------------------
<script type="text/javascript">
var total = 0;
function comprobarChecks()
{
var checks = document.getElementsByTagName("input"); //recojo todos los input
for(i=0;i<checks.length;i++)
{
if(checks[i].type=="checkbox") //solo contemplo los de tipo checkbox
{
if(checks[i].checked) //si esta checkado agrego a total su valor
total += parseFloat(checks[i].value);
}
}
}
</script>
-------------------
(html)
(de inicio marco unos cuantos checks)
<body onload="comprobarChecks();">
<input type="checkbox" value="3.45" checked="checked" id="Checkbox0" />
<input type="checkbox" value="3.23" id="Checkbox1" />
<input type="checkbox" value="3.12" id="Checkbox2" />
<input type="checkbox" value="3.2" checked="checked" id="Checkbox3" />
<input type="checkbox" value="3.90" id="Checkbox4" />
<input type="checkbox" value="3.34" checked="checked" id="Checkbox5" />
<input type="checkbox" value="3.33" id="Checkbox6" />
</body>
--------------------------

saludos.