I have this code:
function updateTextArea() {
var allVals = [];
$('#c_b :checked').each(function() {
allVals.push($(this).val());
jQuery('#referralIds').val(allVals);
});
}
$(function() {
$('#c_b input').click(updateTextArea);
updateTextArea();
});
Whenever a user check a checkbox, a value is added to an INPUT field with the id=referralIds.
My question is, how can I do, so whenever the checkbox(es) are unchecked, the assigned value will be removed from the INPUT?
Thanks.