代码见下面
<form name=hrong>
<input type=checkbox name=All onclick="checkAll('mm')"><br/>
<input type=checkbox name=mm onclick="checkItem('All')"><br/>
<input type=checkbox name=mm onclick="checkItem('All')"><br/>
<input type=checkbox name=mm onclick="checkItem('All')"><br/>
<input type=checkbox name=mm onclick="checkItem('All')"><br/>
<input type=checkbox name=mm onclick="checkItem('All')"><br/><br/>
<input type=checkbox name=All2 onclick="checkAll('mm2')"><br/>
<input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 onclick="checkItem('All2')"><br/></form><SCRIPT LANGUAGE="JavaScript">
function checkAll(str)
{
var a = document.getElementsByName(str);
var n = a.length;
for (var i=0; i<n; i++)
a[i].checked = window.event.srcElement.checked;
}
function checkItem(str)
{
var e = window.event.srcElement;
var all = eval("document.hrong."+ str);
if (e.checked)
{
var a = document.getElementsByName(e.name);
all.checked = true;
for (var i=0; i<a.length; i++)
{
if (!a[i].checked){ all.checked = false; break;}
}
}
else all.checked = false;
}
</SCRIPT>
<form name=hrong>
<input type=checkbox name=All onclick="checkAll('mm')"><br/>
<input type=checkbox name=mm onclick="checkItem('All')"><br/>
<input type=checkbox name=mm onclick="checkItem('All')"><br/>
<input type=checkbox name=mm onclick="checkItem('All')"><br/>
<input type=checkbox name=mm onclick="checkItem('All')"><br/>
<input type=checkbox name=mm onclick="checkItem('All')"><br/><br/>
<input type=checkbox name=All2 onclick="checkAll('mm2')"><br/>
<input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 onclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 onclick="checkItem('All2')"><br/></form><SCRIPT LANGUAGE="JavaScript">
function checkAll(str)
{
var a = document.getElementsByName(str);
var n = a.length;
for (var i=0; i<n; i++)
a[i].checked = window.event.srcElement.checked;
}
function checkItem(str)
{
var e = window.event.srcElement;
var all = eval("document.hrong."+ str);
if (e.checked)
{
var a = document.getElementsByName(e.name);
all.checked = true;
for (var i=0; i<a.length; i++)
{
if (!a[i].checked){ all.checked = false; break;}
}
}
else all.checked = false;
}
</SCRIPT>
function hiddenFunc()
{
for(var n=0;n<document.getElementsByName('rd').length;n++)
document.getElementsByName('rd')[n].style.display='none';
}
function displayFunc()
{
for(var n=0;n<document.getElementsByName('rd').length;n++)
document.getElementsByName('rd')[n].style.display='';
}
</script>
<input type="radio" name="rd" value="1">
<input type="radio" name="rd" value="2">
<input type="radio" name="rd" value="3">
<input type="radio" name="rd" value="4">
<input type="radio" name="rd" value="5">
<input type="radio" name="rd" value="6">
<input type="button" onclick="hiddenFunc()" value="隐藏">
<input type="button" onclick="displayFunc()" value="显示">
显示和隐藏还可以通过改变元素的style.visibility的属性来进行
visible是显示
hidden是隐藏
两种方法的异同,很容易看出来。楼主,Good luck!
<head>
<title></title>
</head>
<body><input type=checkbox id=showAll> show all
<br>
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
<input type=radio style="display:expression(showAll.checked?'':'none')">
</body>
</html>
不过是复选框,多得很……
我是很婆妈的……
把你的方法改进了一下……
<style>
.dm{display:expression(showAll.checked?'':'none')}
</style>
<input type=checkbox id=showAll> show all
<br>
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
<input type=radio class="dm">
希望不见怪