<script src="http://code.jquery.com/jquery-1.4.4.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $(":checkbox").each(function (i) { if (this.id.indexOf("cbl") != -1) { this.onclick = function () { AddTips(this.id) }; } });// var Tips = document.getElementById("Tips");// Tips.innerHTML = ""; $("#Tips").html(""); }); function AddTips(Id) { //var Tips = document.getElementById("Tips"); var $Tips = $("#Tips"); $("label").each(function (i) { if (this.htmlFor == Id) { if ($("#" + Id).is(":checked")) { $Tips.html($Tips.html() + $(this).html() + ","); } else { var x = $(this).html() + ","; $Tips.html($Tips.html().replace(x, "")); } } });// var items = $("label");// for (var i = 0; i < items.length; i++) {// if (items[i].htmlFor == Id) {// if (document.getElementById(Id).checked) {// Tips.innerHTML += items[i].innerHTML + ",";// }// else {// var x = items[i].innerHTML + ",";// Tips.innerHTML = Tips.innerHTML.replace(x, "");// }// }// } } </script> <div id="Tips"></div>
<asp:CheckBoxList ID="cbl" runat="server">
</asp:CheckBoxList>
CS.
for (int i = 0; i < 10; i++)
{
cbl.Items.Add(new ListItem(i.ToString()));
}