87,910
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script type="text/javascript">
function chkall(){
for(var i=0;i <document.form1.elements.length;i++) {
var e=document.form1.elements[i];
if(e.checked==false){
e.checked=true;
}else{
e.checked=false;
}
}
}
var check_flag=true;
function chk(){
var chkall=document.getElementsByName('chks');
if(check_flag==true){
if(chkall.length>0){
for(var i=0;i<chkall.length;i++){
if(chkall[i].checked==false){
chkall[i].checked=true;
}
else if(chkall[i].checked==true){
chkall[i].checked=true;
check_flag=false;
}
}
}
}
else if(check_flag==false){
if(chkall.length>0){
for(var i=0;i<chkall.length;i++){
if(chkall[i].checked==false){
chkall[i].checked=false;
}
else if(chkall[i].checked==true){
chkall[i].checked=false;
check_flag=true;
}
}
}
}
}
</script></head>
<body>
<form name="form1" >
<input type="button" name="chkes" onclick="chkall()" value="chkall"/>
<br>
<input type="button" name="chkesss" onclick="chk()" value="用这个"/>
<br>
<input type="checkbox" name="chks" value="1"/>
<br/>
<input type="checkbox" name="chks" value="2"/>
<br/>
<input type="checkbox" name="chks" value="3"/>
<br/>
<input type="checkbox" name="chks" value="4"/>
<br/>
<input type="checkbox" name="chks" value="5"/>
<br/>
<input type="checkbox" name="chks" value="6"/>
<br/>
<input type="checkbox" name="chks" value="7"/>
<br/>
<input type="checkbox" name="chks" value="8"/>
<br/>
<input type="checkbox" name="chks" value="9"/>
<br/>
</form>
</body>
</html>
<html>
<head>
<script type="text/javascript">
function chkall(){
for(var i=0;i <document.form1.elements.length;i++) {
var e=document.form1.elements[i];
if(e.checked==false){
e.checked=true;
}else{
e.checked=false;
}
}
}
var check_flag=true;
function chk(){
var chkall = document.getElementsByName('chks');
var n = 0;
for(var i=0;i<chkall.length;i++) if(chkall[i].checked) n++;
if(n==chkall.length) for(var i=0;i<chkall.length;i++) chkall[i].checked = false;
else for(var i=0;i<chkall.length;i++) chkall[i].checked = true;
}
</script></head>
<body>
<form name="form1" >
<input type="button" name="chkes" onclick="chkall()" value="chkall"/>
<br>
<input type="button" name="chkesss" onclick="chk()" value="用这个"/>
<br>
<input type="checkbox" name="chks" value="1"/>
<br/>
<input type="checkbox" name="chks" value="2"/>
<br/>
<input type="checkbox" name="chks" value="3"/>
<br/>
<input type="checkbox" name="chks" value="4"/>
<br/>
<input type="checkbox" name="chks" value="5"/>
<br/>
<input type="checkbox" name="chks" value="6"/>
<br/>
<input type="checkbox" name="chks" value="7"/>
<br/>
<input type="checkbox" name="chks" value="8"/>
<br/>
<input type="checkbox" name="chks" value="9"/>
<br/>
</form>
</body>
</html>
<META NAME="Author" CONTENT="theforever(碧海情天),赵亮">
<meta http-equiv="blog" content="blog.csdn.net/theforever">
<meta http-equiv="email" content="theforever@163.com">
<META NAME="Keywords" CONTENT="theforever,csdn,碧海情天,赵亮">
<script type="text/javascript">
function chkall(){
for(var i=0;i <document.form1.elements.length;i++) {
var e=document.form1.elements[i];
if(e.checked==false){
e.checked=true;
}else{
e.checked=false;
}
}
}
function theforever(){
var chks=document.getElementsByName('chks');
var check_num;
if(chks.length>0){
check_num=0;
for(var i=0;i<chks.length;i++){
if(chks[i].checked==true) check_num++;
}
check_num=!(check_num==chks.length);
for(var i=0;i<chks.length;i++){
chks[i].checked=check_num;
}
}
}
</script></head>
<body>
<form name="form1" >
<input type="button" name="chkOthers" onclick="反选()" value="反选"/>
<br>
<input type="button" name="chkAll" onclick="theforever()" value="用这个"/>
<br>
<input type="checkbox" name="chks" value="1"/><br/>
<input type="checkbox" name="chks" value="2"/><br/>
<input type="checkbox" name="chks" value="3"/><br/>
<input type="checkbox" name="chks" value="4"/><br/>
</form>
</body>
</html>
<META NAME="Author" CONTENT="theforever(碧海情天),赵亮">
<meta http-equiv="blog" content="blog.csdn.net/theforever">
<meta http-equiv="email" content="theforever@163.com">
<META NAME="Keywords" CONTENT="theforever,csdn,碧海情天,赵亮">
<script type="text/javascript">
function chkall(){
for(var i=0;i <document.form1.elements.length;i++) {
var e=document.form1.elements[i];
if(e.checked==false){
e.checked=true;
}else{
e.checked=false;
}
}
}
function theforever(){
var chks=document.getElementsByName('chks');
var check_num;
if(chks.length>0){
check_num=0;
for(var i=0;i<chks.length;i++){
if(chks[i].checked==true) check_num++;
}
for(var i=0;i<chks.length;i++){
chks[i].checked=check_num==chks.length?false:true;
}
}
}
</script></head>
<body>
<form name="form1" >
<input type="button" name="chkOthers" onclick="反选()" value="反选"/>
<br>
<input type="button" name="chkAll" onclick="theforever()" value="用这个"/>
<br>
<input type="checkbox" name="chks" value="1"/><br/>
<input type="checkbox" name="chks" value="2"/><br/>
<input type="checkbox" name="chks" value="3"/><br/>
<input type="checkbox" name="chks" value="4"/><br/>
</form>
</body>
</html>