<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=javascript>
<!-- 全选 -->
function selectall(v){
var f = document.forms["resultlist"];
for (i=0;i<f.elements.length;i++)
if (f.elements[i].name=="userid") f.elements[i].checked = v;
document.forms["resultlist"].elements["clickall"].checked = v;
document.forms["resultlist"].elements["clickall2"].checked = v;
}
<!-- 改变选择列的颜色 -->
function changechecked(checkbut){
var v =checkbut.checked;
if (v) {
checkbut.checked = true;
if(isallselected()){
document.forms["resultlist"].elements["clickall"].checked = true;
document.forms["resultlist"].elements["clickall2"].checked = true;
}
}else{
document.forms["resultlist"].elements["clickall"].checked = false;
document.forms["resultlist"].elements["clickall2"].checked = false;
checkbut.checked = false;
}
}
<!-- 是否有选中? -->
function isselected(){
var f = document.forms["resultlist"];
for (i=0;i<f.elements.length;i++)
if ((f.elements[i].name=="userid") && (f.elements[i].checked)) return true;
return false;
}
<!--是否全部选中? -->
function isallselected(){
var selectcount = 0;
var allcount=0;
var f = document.forms["resultlist"];
for(i=0;i<f.elements.length;i++){
if (f.elements[i].checked){
selectcount = selectcount + 1;
}
}
for(i=0;i<f.elements.length;i++){
if ((f.elements[i].name.indexOf("select")>-1)){
allcount = allcount+1;
}
}
if(selectcount==allcount)
return true;
else
return false;
}
</SCRIPT>
<FORM name=resultlist action=list method=post>
<INPUT onclick=selectall(this.checked) type=checkbox name=clickall>全选
<INPUT onclick=changechecked(this) type=checkbox value=on name=userid>
<INPUT onclick=changechecked(this) type=checkbox value=on name=userid>
<INPUT onclick=changechecked(this) type=checkbox value=on name=userid>
<INPUT onclick=changechecked(this) type=checkbox value=on name=userid></TD>
<INPUT onclick=selectall(this.checked) type=checkbox name=clickall2>全选
</FORM>
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073