我在后台为CheckboxList赋值如CheckBoxList1.Items.Add(p.pName);
在前台 
$('input:[type="checkbox"]').each(function () {                if ($(this).attr('checked')) {
      var mydata = { "PName": $(this).val(), "UserId": $("#hduserId").val() }
      $.post("../Handler/UserAndPower.ashx?Id=" + 1, mydata, function (data) {
        if (data) {
      } else { a = false; }
       });
}
  });我 $(this).val() 的值是 on  一开始我这么写是没有问题的... 但是后来也不知道该什么了 就是on了?
试了 index html text 都不能取值 求帮忙看下谢谢 有什么解决办法 或者绕过去也可以! 谢谢

解决方案 »

  1.   

    <asp:CheckBoxList ID="cbCheck" runat="server" RepeatColumns="5" AppendDataBoundItems="true"
                        RepeatDirection="Horizontal" Width="410px">
                    </asp:CheckBoxList>    
     for (int i = 0; i < cbCheck.Items.Count; i++)
                    {
                        if (cbCheck.Items[i].Selected)
                        {
                            IDs += cbCheck.Items[i].Value + ",";
                        }
                    }
      

  2.   

    $('input:[type="checkbox"]').each(function () {       if ($(this).attr('checked')) {
          var mydata = { "PName": $(this).val(), "UserId": $("#hduserId").all() }
          $.post("../Handler/UserAndPower.ashx?Id=" + 1, mydata, function (data) {
            if (data) {
          } else { a = false; }
           });
    }
      });
      

  3.   


    谢谢回答.  这个不可以唉..
    我的源文件代码是这样了
    <tr>
    <td><input id="CheckBoxList1_0" type="checkbox" name="CheckBoxList1$0" /><label for="CheckBoxList1_0">普通用户</label></td><td><input id="CheckBoxList1_1" type="checkbox" name="CheckBoxList1$1" /><label for="CheckBoxList1_1">审核权限</label></td><td><input id="CheckBoxList1_2" type="checkbox" name="CheckBoxList1$2" /><label for="CheckBoxList1_2">管理权限</label></td>
    </tr><tr>
    <td><input id="CheckBoxList1_3" type="checkbox" name="CheckBoxList1$3" /><label for="CheckBoxList1_3">导出权限</label></td><td><input id="CheckBoxList1_4" type="checkbox" name="CheckBoxList1$4" /><label for="CheckBoxList1_4">超级管理员</label></td><td></td>
    </tr>