Im passing some values with ID’s from selected check box’s
Im collecting the values in an array to post however I also want to sum the values in the titles but I cant get it to do this…
where am I going wrong ? I know its in the calling of the variable that is returned but im not sure how to GET it
function doAlloMath(){
var sum=0;
alert($("input[name=alloInv]:checked").map(function () {return this.value;}).get().join(","));
alert($("input[name=alloInv]:checked").map(function () {return this.title;}).get().join(","));
alert($("input[name=alloInv]:checked").each(function (a,b) {sum += parseFloat ($(this.title)); return sum;}).get());
}
A checkbox does’nt have a value unless it’s explicitly set. To see if the checkbox is checked or not you need to use
prop('checked');You could try something more like this: