1、需求:我現在頁面上有放兩個單選控件,現在要通過判斷不同的單選控件來對頁面上的标簽進行顯示和隐藏操作
2、控件如下
<asp:RadioButtonList ID="rb_pumpParameter" TabIndex="1" runat="server" RepeatColumns="9"
RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem οnclick="pumpParameter();" Value="管式泵">管式泵</asp:ListItem>
<asp:ListItem οnclick="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
轉載于:https://www.cnblogs.com/zhengwei-cq/p/7084394.html