Home >Backend Development >C#.Net Tutorial >CheckBoxList multi-selection style jquery, C# gets selected items
Use jquery and C# to obtain CheckBoxList selections. The implementation is as follows. Interested friends can refer to the following
The PHP code is as follows:
.checkboxlist label { margin-right: 20px; }
The PHP code is as follows:
var label; $("#ddlplatform input:checkbox:checked").each(function () { label += $(this).next().html(); });
The PHP code is as follows:
<asp:CheckBoxList ID="ddlplatform" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" CssClass="checkboxlist"> <asp:ListItem Value="APP">APP</asp:ListItem> <asp:ListItem Value="移动触屏">移动触屏</asp:ListItem> <asp:ListItem Value="PC">PC</asp:ListItem> <asp:ListItem Value="微信">微信</asp:ListItem> <asp:ListItem Value="微博">微博</asp:ListItem> </asp:CheckBoxList>
The PHP code is as follows:
//使用平台 string Platfrom = string.Empty; foreach (ListItem li in this.ddlplatform.Items) { if (li.Selected) { Platfrom += li.Text + ","; } } Platfrom = Platfrom.TrimEnd(',');