I have many checkboxs as below,
Coo
Or you use can do using array like shown below
var checkBoxArray = new Array();
var areaofinterest = '';
$(':checkbox:checked').each(function(i){
checkBoxArray .push($(this).attr("value"));
});
if (checkBoxArray .length == 0) {
} else {
while (checkBoxArray .length != 0) {
if (checkBoxArray .length == 1) {
areaofinterest += checkBoxArray .pop();
} else {
areaofinterest += (checkBoxArray .pop() + ",");
}
}
}
console.log(areaofinterest);
though you will get String in reverse order.