如何使用Javascript检查RadioButtonList [英] How to Check RadioButtonList using Javascript

查看:53
本文介绍了如何使用Javascript检查RadioButtonList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查RadioButtonList的任何值

How to Check any value of RadioButtonList

<script>
document.getElementById("<%=rblTitle.ClientID %>").selected = document.getElementById("<%= hfTITLE.ClientID %>").value;
</script>




<asp:RadioButtonList ID="rblTitle" runat="server" RepeatDirection="Horizontal">
                                   <asp:ListItem Text="Mr" Value="Mr"></asp:ListItem>
                                   <asp:ListItem Text="Mrs" Value="Mrs"></asp:ListItem>
                                   <asp:ListItem Text="Ms" Value="Ms"></asp:ListItem>
                               </asp:RadioButtonList>







如何选择或检查javascript




How to select or check by javascript

推荐答案

我建议你去jQuery,它非常简单。



执行任何jQuery代码的步骤

1.从官方网站<下载jQuery文件/ a> [ ^ ]。

2.放入你的内部项目并包含在你的html(内部头部)中,如下所示。

I would suggest you to go for jQuery, in which it is be very simple.

Steps to execute any jQuery code
1. Download the jQuery file from Official Website[^].
2. Place inside your project and include in your html (inside head section) like below.
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>





提出问题的解决方案

您为RadioButtonList提供的代码将在下面的浏览器中呈现。



Solution for the asked question
The code provided by you for RadioButtonList will be rendered in browser like below.

<table id="rblTitle">
    <tbody>
        <tr>
            <td>
                <input type="radio" value="Mr" name="rblTitle" id="rblTitle_0">
                <label for="rblTitle_0">Mr</label>
            </td>
            <td>
                <input type="radio" value="Mrs" name="rblTitle" id="rblTitle_1">
                <label for="rblTitle_1">Mrs</label>
            </td>
            <td>
                <input type="radio" value="Ms" name="rblTitle" id="rblTitle_2">
                <label for="rblTitle_2">Ms</label>
            </td>
        </tr>
    </tbody>
</table>



现在你必须使用jQuery在客户端处理这段代码。



因此,要获取所选的单选按钮值,请在页面中使用以下javaScript代码。


Now you have to work on this code in client-side using jQuery.

So, to get the selected value of radio button, use the below javaScript code in your page.

<script type="text/javascript">


(document).ready(function(){
//获取单选按钮。
var rblTitle =
(document).ready(function () { // Get the Radio Buttons. var rblTitle =


('#rblTitle')。find('input:radio');

rblTitle.click(function(){
//获取所选值
alert(
('#rblTitle').find('input:radio'); rblTitle.click(function () { // Get the selected value alert(


这篇关于如何使用Javascript检查RadioButtonList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆