Created
July 28, 2017 14:03
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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