Somando valores de checkboxes com JQuery
Uma diquinha rápida mas que pode ser útil para alguem que queira agilizar seu trabalho :D
[source lang="html"]
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<form>
<input type="checkbox" name="newsletter" checked="checked" value="1" />
<input type="checkbox" name="newsletter" value="2" />
<input type="checkbox" name="newsletter" value="3" />
<input type="checkbox" name="newsletter" checked="checked" value="4" />
<input type="checkbox" name="newsletter" value="5" />
<input id='result' type="text" value='0' />
</form>
<script>
function sumChecked() {
var result = $("input:checked");
var i=0;
var total = 0;
for (i=0;i<result.length;i++)
{
total = total+parseInt(result[i].value);
}
$("#result").val(total);
}
sumChecked();
$(":checkbox").click(sumChecked);
</script>
</body>
</html>
[/source]