您好,如何使用jquery从checkboxlist控件中获取复选框的selectedindex?
更新:
此代码为我提供的选定索引等于0,请修改
<asp:CheckBoxList ID="chkListGroups" runat="server"
style="position:absolute; top: 1115px; left: 745px; bottom: 371px;"
DataSourceID="SqlDSGroups" DataValueField="Groups"
onclick="test()">
</asp:CheckBoxList>
....................
java script function
.....................
function test(){
$('#<%=chkListGroups.ClientID %>').click(function() {
var selectedIndex = $('#<%=chkListGroups.ClientID %>').index($(this));
alert(selectedIndex);
});
}发布于 2010-05-22 01:04:44
如果需要上一次选中复选框的索引,则如下所示
var query = (from o in CheckBoxList1.Items.OfType<ListItem>()
where o.Selected
select o).Take(1).Reverse().ToList(); https://stackoverflow.com/questions/2884014
复制相似问题