如何从客户端的单选按钮列表中获取选定的值? [英] How to get selected value from radio button list in client side ?

查看:100
本文介绍了如何从客户端的单选按钮列表中获取选定的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有5个listitems的radiobuttonlist,需要从客户端获取选择的项目,来自radiobuttonlist的事件需要触发,而不是来自任何按钮点击事件或其他一些事情



Hi I have radiobuttonlist with 3 listitems,from client side in need to get which item is selected,event need trigger from radiobuttonlist,not from any button click event or some other things

<asp:RadioButtonList ID="radListType"   runat="server">
                    <asp:ListItem Selected="True" Value="User" >User</asp:ListItem>
                    <asp:ListItem Value="Public" >Public</asp:ListItem>
                    <asp:ListItem Value="Private" >Private</asp:ListItem>
                </asp:RadioButtonList>





如果检查公共,我需要获得公共价值,来自radiobuttonlist的任何活动





问候

Aravind



in this if check "Public",i need to get "Public" value,any event from radiobuttonlist


Regards
Aravind

推荐答案

以下是获取所选单选按钮值的代码:

Below are the code to get selected radio button value :
var checked_radio =


[id * = radListType]输入:检查);
var value = checked_radio.val();
("[id*=radListType] input:checked"); var value = checked_radio.val();



希望,它会起作用...... !


Hopefully, It will work ...!


如果您想从客户端处理点击事件,您可以实现以下目标。



If you want to handle click event from client side you can achieve as below.

    <asp:RadioButtonList ID="radListType" AutoPostBack="False"  runat="server">
        <asp:ListItem class="radio-type" Selected="True" Value="User" >User</asp:ListItem>
        <asp:ListItem class="radio-type" Value="Public" >Public</asp:ListItem>
        <asp:ListItem class="radio-type" Value="Private" >Private</asp:ListItem>
    </asp:RadioButtonList>
    
<script>


这篇关于如何从客户端的单选按钮列表中获取选定的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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