Eine reine JavaScript-Lösung:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<html>
<head>
<script type="text/javascript">
function addValues(){
var sum = 0;
for(var i = 0; i < document.forms[0].length; ++i){
if(document.forms[0].elements[i].type == "checkbox" && document.forms[0].elements[i].checked){
sum += (document.forms[0].elements[i].value * 1);
}
}
document.forms[0].ausgabe.value = sum;
}
</script>
</head>
<body>
<form name="test">
<input type="checkbox" value="5" onClick="addValues();">1<br />
<input type="checkbox" value="5" checked onClick="addValues();">2<br />
<input type="checkbox" value="5" checked onClick="addValues();">3<br />
<input type="checkbox" value="5" checked onClick="addValues();">4<br />
<input type="checkbox" value="5" checked onClick="addValues();">5<br />
<input type="checkbox" value="5" checked onClick="addValues();">6<br />
<input type="text" name="ausgabe">
</form>
</body>
</html>