I'm using ASP.NET asp:checkboxlist control with 36 listitems. which displays 36 checkboxes. in HTML it displays like below table. I also have a I would like to add the checked items in this div in sorted way. But when they uncheck the checkbox it should remove from the div. I display it , (comma separeted).
like:
selected : 5,6,9,12,25
I try to use Jquery. Below I try to add a click on the Checkboxes and I try to concat the values, but I'm struggling with the code. Can someone give some guide? at least what methods and how to sort in the div? It only contains numbers from 1-36.
$(function () {
var $tblChkBox = $("table.chk input:checkbox");
$tblChkBox.click(function (e) {
$('#chkBoxListNumbers').val($('#chkBoxListNumbers') +',');
});
});
<table id="chkBoxListNumbers" class="chk">
<tr> <td><input id="chkBoxListNumbers_0" type="checkbox" value="1"/></td>
<td><input id="chkBoxListNumbers_1" type="checkbox" value="3"/></td>
<td><input id="chkBoxListNumbers_2" type="checkbox" value="4"/></td>
<td><input id="chkBoxListNumbers_3" type="checkbox" value="5"/></td>
</tr>
</table>