jQuery(function($) {
var $text = $('#text-input'),
$box = $('.my-checkbox');
$box.on('click', function() {
var values = $text.val().split(",") || [];
$box.each(function() {
if($(this).prop("checked")){
if(values.join("").indexOf(this.value) < 0){
values.push(this.value);
}
} else {
var index = values.indexOf(this.value);
if(index >=0){
values.splice(index, 1);
}
}
});
$text.val(values.join(','));
});
});