Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save atsea/258096e267daf6f54fbe8599c4a67c2e to your computer and use it in GitHub Desktop.
Save atsea/258096e267daf6f54fbe8599c4a67c2e to your computer and use it in GitHub Desktop.
jQuery use .get().join() methods to group checkbox values together in email receipt.
/**
* CHECKBOX GROUP
*
* Uses .get().join() methods to group values together in email receipt.
* @return array
*/
function Populate(){
var cbArray = [];
vals = $('#cb_type_id input[type="checkbox"]:checked').map(function() {
return this.value;
}).get().join(',');
console.log(vals);
$('#record_type_array').val(vals);
console.log('asdf: ' + $('#record_type_array').val());
}
$('#cb_type_id input[type="checkbox"]').on('change', function() {
Populate()
}).change();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment