1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="SelectUsers.aspx.cs" Inherits="Work_SelectUsers" %> 2 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml"> 5 <head id="Head1" runat="server"> 6 <title></title> 7 <link href="../css/GridView.css" rel="stylesheet" type="text/css" /> 8 <script src="../js/jquery-1.3.2.min.js" type="text/javascript"></script> 9 </head> 10 <body> 11 <form id="form1" runat="server"> 12 <div style="text-align: center"> 13 <div style="text-align: left"> 14 <button class="selected"> 15 确定</button> 16 </div> 17 <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" 18 Style="width: 80%; text-align: center" CssClass="Grid"> 19 <FooterStyle CssClass="GridFooter" /> 20 <RowStyle CssClass="Row" /> 21 <Columns> 22 <asp:TemplateField HeaderText="选择"> 23 <ItemTemplate> 24 <input type="checkbox" value=" <%# Eval("id")%>" /> 25 </ItemTemplate> 26 <HeaderStyle Wrap="False" /> 27 <ItemStyle Wrap="False" Width="50px" HorizontalAlign="Center" /> 28 </asp:TemplateField> 29 <asp:TemplateField HeaderText="姓名"> 30 <ItemTemplate> 31 <%# Eval("name")%> 32 </ItemTemplate> 33 <HeaderStyle Wrap="False" /> 34 <ItemStyle Wrap="False" CssClass="name" /> 35 </asp:TemplateField> 36 </Columns> 37 <HeaderStyle CssClass="HeadingCell" /> 38 <AlternatingRowStyle BorderStyle="None" CssClass="AlternatingRow" /> 39 </asp:GridView> 40 <div style="text-align: left"> 41 <button class="selected"> 42 确定</button> 43 </div> 44 </div> 45 </form> 46 <script type="text/javascript"> 47 $('.selected').click(function () { 48 var userInfos = []; 49 $('table :checkbox:checked').each(function () { 50 userInfos.push({ 51 ID: $(this).val(), 52 Name: $(this).closest('tr').find('.name').text() 53 }) 54 }); 55 window.returnValue = userInfos; 56 window.close(); 57 }); 58 </script> 59 </body> 60 </html>
求各位大神帮我看看,怎么获得里面被选中的值!谢谢。。。。
ID: $(this).val(),
你这句话就是获得的那个checkbox的值啊,你放在了json对象中了。
你的jq代码里不是写了嘛。~~~$(this).val();