I want to loop through the checkboxgroup \'locationthemes\' and build a string with all selected values. So when checkbox 2 and 4 are selected the result would be: \"3,8\">
$('input:checkbox[name=locationthemes]:checked').each(function() { // add $(this).val() to your array });
Working Demo
OR
Use jQuery's is() function:
$('input:checkbox[name=locationthemes]').each(function() { if($(this).is(':checked')) alert($(this).val()); });