mercredi 25 mars 2015

get the value of all selected checkboxes in textbox

I am trying to create a check box with some value and then display the values of selected check boxes separated by a comma.


I can create a checkbox but I am unable to display the values in a text box. Please help.


http://ift.tt/1btO03Z



function displayCheckbox(){
$("input:checkbox").change(function() {
selectedCB = [];
notSelectedCB = [];
$("input:checkbox").each(function() {
if ($(this).is(":checked")) {
CountSelectedCB[0] = $(this).attr("id");
}
});
$('input[name=selectedCB]').val(CountSelectedCB);
});
}




Aucun commentaire:

Enregistrer un commentaire