<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="eachcheckbox.aspx.cs" Inherits="WebApplication1.eachcheckbox" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var cnt = 0; var sel = ''; $("#btnclick").click(function () { //debugger; var items = jQuery("input:checked[guid]"); items.each(function () { if (jQuery(this).attr("guid")) { sel += "," + jQuery(this).attr("guid"); cnt += 1; } else { } }); if (cnt < 1) { alert('請選擇記錄!'); return false; } else { // if (confirm('肯定要刪除嗎?')) { alert(sel); // } } sel = ""; });//獲取選中的是哪個 $("#chkIsPublic").click(function () { //對單選按鈕單擊 var ss = $('input:radio:checked').val(); alert(ss); }); }); //複選框全選 function aa(obj) { $(".checkBox>input").attr("checked", $(obj).attr("checked")); $(".checkBox").attr("checked", $(obj).attr("checked")); } </script> </head> <body> <form id="form1" runat="server"> <input type="button" id="btnclick" value="獲取選中的是哪個" /> <div> <table> <tr> <td colspan="3"><input type="checkbox" id="checkAll" onclick="aa(this)" />全選</td> </tr> <tr> <td> <input type="checkbox" id="chkguid" guid="class1" class="checkBox" />班級1 </td> <td> <input type="checkbox" id="Checkbox1" guid="class2" class="checkBox" />班級2 </td> <td> <input type="checkbox" id="Checkbox2" guid="class3" class="checkBox" />班級3 </td> </tr> </table> </div> <div> ---------------------------------------------------------------------------------------------- </div> <asp:RadioButtonList ID="chkIsPublic" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" RepeatColumns="5"> <asp:ListItem Value="0" Selected="True">租賃</asp:ListItem> <asp:ListItem Value="1">購買</asp:ListItem> <asp:ListItem Value="2">代理商</asp:ListItem> </asp:RadioButtonList> </form> </body> </html>