Podés hacerlo así sin necesidad de jQuery
Código HTML:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <input type="checkbox" class="x" name="uno" /><br /> <input type="checkbox" class="x" name="dos" /><br /> <input type="checkbox" class="x" name="tres" /><br /> Totales:
<input type="text" id="totales" class="m" /><br /><script type="text/javascript"> //<![CDATA[
var cboxes = document.getElementsByTagName("input");
for(var i=0; i < cboxes.length; i++){
var valor = cboxes[i].checked;
// usamos className para < ie9
if(cboxes[i].className == 'x'){
// verificamos addEventListener para < ie9
if(!cboxes[i].addEventListener){
cboxes[i].attachEvent("onclick", contar);
}else{
cboxes[i].addEventListener("click", contar, false);
}
}
}
function contar(){
var totales = "";
var contador = 1;
var casillas = document.getElementsByTagName("input");
for (var i=0; i < casillas.length; i++){
var valor = casillas[i].checked;
var clase = casillas[i].className;
if(clase == 'x'){
if(valor == true){
totales = contador++;
}
}
}
document.getElementById("totales").value= totales
}
//]]>
Saludos