单选按钮列表选择事件的Java脚本代码 [英] java script code for radio button list selection event
本文介绍了单选按钮列表选择事件的Java脚本代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生您好,
我在asp.net Web应用程序中有一个带有两个列表项YES和NO的单选按钮列表,以及一个Pannel
我想做的是,如果我选择是"单选按钮,则面板"将保持可见模式,但是如果选择否",则面板将不可见.
如果有人有示例代码,请发送给我们.
Hello sir,
i have a radio button list with two list items YES & NO.and a Pannel in my asp.net web application
what i want to do is if i select the YES radio button then Pannel will remain in visible mode but if I select NO then my pannel becomes unvisible.
if any one have the sample code then please send us.
thanks in advance.
推荐答案
尝试以下代码:
Try below code:
if(document.getElementById("rbYes").checked == true)
{
document.getElementById('Panel1').style.display = "none";
}
else
{
document.getElementById('Panel1').style.display = "block";
}
将rbYes
和Panel1
分别替换为id为yes单选按钮和面板.
希望对您有所帮助!
Replace rbYes
and Panel1
with id of yes radiobutton and panel respectively.
Hope it helps!
如果它是radiobuttonlist
尝试类似的方法,尽管我没有测试它是否可以工作.
If it is aradiobuttonlist
Try something like though I didn''t test it should work.
function GetRadioButtonValue()
{
var rad = document.getElementsByName("radid");
for (var j = 0; j < rad.length; j++)
{
if (radio[j].value='Yes'){
document.getElementById('Panelid').style.display = "none";
}
else
{
document.getElementById('Panelid').style.display = "block";
}
}
}
这篇关于单选按钮列表选择事件的Java脚本代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文