如:
<input type="radio" name="a1" value="1" checked="checked">选项1
<input type="radio" name="a1" value="2">选项2<input type="radio" name="a2" value="1" checked="checked">选项A
<input type="radio" name="a2" value="2">选项B<div id="a3" name=a3 style="display:none;">
<input type=radio name=a3 value=1>隐藏选项1
<input type=radio name=a3 value=2>隐藏选项2
</div>需要的效果:
只有在选择“a1=2”“a2=2”的时候,才显示隐藏的“a3”,否则“a3”为隐藏状态,请高手给一个具体的javascript写法,谢谢!!
<input type="radio" name="a1" value="1" checked="checked">选项1
<input type="radio" name="a1" value="2">选项2<input type="radio" name="a2" value="1" checked="checked">选项A
<input type="radio" name="a2" value="2">选项B<div id="a3" name=a3 style="display:none;">
<input type=radio name=a3 value=1>隐藏选项1
<input type=radio name=a3 value=2>隐藏选项2
</div>需要的效果:
只有在选择“a1=2”“a2=2”的时候,才显示隐藏的“a3”,否则“a3”为隐藏状态,请高手给一个具体的javascript写法,谢谢!!
解决方案 »
- 求解 九九乘法表这样写不对吗?
- 如何判断两个结果集中checkbox选中了重复值?
- js掉后后台得到flv播放路径,并添加到FLASH路径中,有时显示有时候不显示
- extjs下根据导航树动态调用tabpanel的问题
- js 在div中创建表格,在表格中添加checkbox 无法取到checkbox对象
- innerHTML怪问题
- 高手帮忙看下,小弟想学这个!
- 怎么能让某个图片随机出现在页面任何位置?/
- 一个function a()用setTimeout调用自己,我多次执行a(),会不会......?
- js图片轮播的源码,新人求助
- JavaScript Table排序 2.0 补充
- 用href="#top"可以链接到页首,为什么不能用href="bottom"链接到页底
<input type="radio" name="a1" onclick="show(this)" value="1" checked="checked">选项1
<input type="radio" name="a1" onclick="show(this)" value="2">选项2 <input type="radio" name="a2" onclick="show(this)" value="1" checked="checked">选项A
<input type="radio" name="a2" onclick="show(this)" value="2">选项B <div id="a3" name=a3 style="display:none;">
<input type=radio name=a3 value=1>隐藏选项1
<input type=radio name=a3 value=2>隐藏选项2
</div> <script>
var showFlag={};
function show(o){
showFlag[o.name]=o.value;
if(showFlag.a1=="2"&&showFlag.a2=="2"){
document.getElementById("a3").style.display="";
}else{
document.getElementById("a3").style.display="none";
}
}
</script>
<HTML>
<HEAD>
<TITLE>标题 </TITLE> <SCRIPT LANGUAGE="JAVASCRIPT">
function abc(){
var a1=document.getElementsByName("a1");
var a2=document.getElementsByName("a2");
var flag=false;
for(var i=0;i<a1.length;i++){
if(a1[i].checked){
if(a1[i].value==2)flag=true;
}
}
if(flag){
for(var i=0;i<a2.length;i++){
if(a2[i].checked){
if(a2[i].value==2)flag=false;
}
}
if(!flag){
document.getElementById("a3").style.display="";
return;
}
}
document.getElementById("a3").style.display="none";
}
</SCRIPT> </HEAD>
<body>
<input type="radio" name="a1" value="1" checked="checked" onclick="abc()">选项1
<input type="radio" name="a1" value="2" onclick="abc()">选项2 <input type="radio" name="a2" value="1" checked="checked" onclick="abc()">选项A
<input type="radio" name="a2" value="2" onclick="abc()">选项B <div id="a3" name=a3 style="display:none;">
<input type=radio name=a3 value=1>隐藏选项1
<input type=radio name=a3 value=2>隐藏选项2
</div>
</body>
</HTML>