RadioButtonList控件如何取得选中的值

1、需求:我现在页面上有放两个单选控件,现在要通过判断不同的单选控件来对页面上的标签进行显示和隐藏操作

2、控件如下

<asp:RadioButtonList ID="rb_pumpParameter" TabIndex="1" runat="server" RepeatColumns="9" 
RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem onclick="pumpParameter();" Value="管式泵">管式泵</asp:ListItem>
    <asp:ListItem onclick="pumpParameter();" Value="抽稠泵">抽稠泵</asp:ListItem>
</asp:RadioButtonList>
View Code

3、我在控件中都加了onclick方法,也就是单我选择这个控件时会走这个方法,在这个方法中我通过判断哪个按按钮被选中了,然后来进行我想要的操作,在这里我是对页面上的两个标签进行的隐藏,方法如下:

function pumpParameter()
        {
            var rb_pump = document.getElementById("<%=rb_pumpParameter.ClientID%>");
            var radios = rb_pump.getElementsByTagName("INPUT");
            if (radios != null)
            {
                for (var i = 0; i < radios.length; i++)
                {
                   
                    if (radios[i].checked)
                    {
                        if (radios[i].value == "管式泵") {
                            $(".TubingPumpDiameter").css("display", "block");
                            $(".thickeningPumpDiameter").css("display","none");
                        } else {
                            $(".TubingPumpDiameter").css("display", "none");
                            $(".thickeningPumpDiameter").css("display", "block");
                        }                        
                    }        
                }
            }
        }
View Code

 

posted @ 2017-06-27 11:50  爱生活,爱代码  阅读(1759)  评论(0编辑  收藏  举报