-
-
Save AntMooreWebDev/2276fc0a9cbdfabc6e687bb6d07bfe80 to your computer and use it in GitHub Desktop.
Convert Checkboxes or Similar into Comma Separated list
This file contains hidden or 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
var checkedVals = $('input[type=checkbox]:checked').map(function() { | |
return this.value; | |
}).get().join(","); | |
$(*TARGET*).val(checkedVals); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I feel that moving the join to the
checkedVals
variable instantiation makes more sense in this concept. It keeps the setting of the value tidier and allows the computational code to be more contained.