zl程序教程

您现在的位置是:首页 >  前端

当前栏目

asp.net使用jQuery获取RadioButtonList成员选中内容和值示例

NetjQueryASP 使用 获取 示例 内容 成员
2023-06-13 09:15:15 时间

复制代码代码如下:


<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="Web.Default"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
   <title></title>
   <scriptsrc="jquery-1.8.2.min.js"type="text/javascript"></script>
   <linkhref="Base.css"rel="stylesheet"type="text/css"/>
   <styletype="text/css">

   </style>
   <scripttype="text/javascript">
       $(document).ready(function(){
           $("#<%=rblHobbies.ClientID%>input[type=radio]").bind("change",function(){
               if($(this).val()!=""){
                    $("#message").text("Text:"+$(this).next().text()+" Value:"+$(this).val());
               }

           });
       });

   </script>
</head>
<body>
   <formid="form1"runat="server">
   <divstyle="margin:100pxauto;width:400px;height:200px;">
       <fieldsetstyle="width:400px;height:150px">
           <p>
               请选择爱好</p>
           <asp:RadioButtonListID="rblHobbies" runat="server">

               <asp:ListItemValue="1">音乐</asp:ListItem>
               <asp:ListItemValue="2">篮球</asp:ListItem>
               <asp:ListItemValue="3">美剧</asp:ListItem>
               <asp:ListItemValue="4">电影</asp:ListItem>

           </asp:RadioButtonList >
       </fieldset>
       <br/>
       <divid="message"style="color:blue;"></div>
   </div>
   </form>
</body>
</html>