<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
p {margin:0;font-size:12px;line-height:26px;}
</style>
<script type="text/javascript">
function check_all(thisObj_IdOrName,othersObj_IdOrName) {
var checkboxs = document.getElementsByName(othersObj_IdOrName);
//window.alert(thisObj_IdOrName.checked);
//window.alert(checkboxs.length);
for(var i=0; i<checkboxs.length; i++){
checkboxs[i].checked = thisObj_IdOrName.checked;
//window.alert(checkboxs[i].checked);
//window.alert(checkboxs[i].name);
//window.alert(checkboxs[i].type);
//window.alert(checkboxs[i].value);
//window.alert(checkboxs[i].onchecked);
}
//等价于
/*
if(thisObj_IdOrName.checked) {
for(var i=0; i<checkboxs.length; i++) {
checkboxs[i].checked = true;
}
} else {
for(var i=0; i<checkboxs.length; i++) {
checkboxs[i].checked = false;
}
}
*/
//window.alert(checkboxs[0].checked);
if(thisObj_IdOrName.checked) {
document.getElementById("allText").innerHTML = "全不选";
document.getElementById("allText").style.background = "red";
document.getElementById("allText").style.border = "solid 3px #0000ff";
} else {
document.getElementById("allText").innerHTML = "全选";
document.getElementById("allText").style.background = "";
document.getElementById("allText").style.border = "";
}
window.status = "哈哈哈哈";
}
</script>
</head>
<body>
<p><input type="checkbox" id="all" name="all" onclick="check_all(this,'c')" /><span id="allText">全选/全不选</span><!--<div id="allText">全选/全不选</div>--></p>
<p><input type="radio" name="c" value="123" /></p>
<p><input type="radio" name="c" value="456" /></p>
<p><input type="radio" name="c" value="789" /></p>
<p><input type="checkbox" name="c" value="11" /></p>
<p><input type="checkbox" name="c" value="22" /></p>
<p><input type="checkbox" name="c" value="33" /></p>
<p><input type="checkbox" name="c" value="44" /></p>
<p><input type="radio" name="ddd" value="" /></p>
<p><input type="radio" name="ddd" value="" /></p>
<p><input type="radio" name="ddd" value="" /></p>
</body>
</html>