I have a dynamic checkbox list and a textbox and a button. On buttonclick,the value in the textbox is the concatenation of selected checkboxes separated by hyphen(-) as below pic 1.(concatenate selected values in horizontal order) enter image description here I want the values to be concatenated as below pic 2(in vertical order). enter image description here
How can this be achieved. Please find my code as below. //
// // // html
js
function hidecblClaimsCodeDesc() {
var code = "";
var desc = "";
$('input[type=checkbox][id^="CheckBoxList2"]:checked').each(function (index, item) {
if (code.length == 0) {
code = $(item).val();
desc = $(item).next("label").text();
}
else {
code += "," + $(item).val();
desc += "-" + $(item).next("label").text();
}
});
}
Aucun commentaire:
Enregistrer un commentaire