Thread Values mehrerer Checkboxen addieren? (17 answers)
Opened by Gast at 2005-01-25 18:00

renee
 2005-01-26 10:05
#24293 #24293
User since
2003-08-04
14367 articles
ModeratorIn
[Homepage] [default_avatar]
Eine reine JavaScript-Lösung:
Code: (dl )
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>
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Values mehrerer Checkboxen addieren?