`
xiaojunhu
  • 浏览: 30114 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

js 全选 全不选

 
阅读更多

本文介绍的是用JS实现全选全不选的方法,另外,这个代码不是我写的,我只是从公司的项目里提取出来,并总结在此,以便以后复用,呵呵。

functionchkClick(chk,oSrc)...{
if(chk.checked)
chkAll(oSrc);
else
unChkAll(oSrc)
}


functionchkAll(oSrc)...{
oSrc
=eval(oSrc).rowId;
if(oSrc!=null)
...{
if(oSrc.length==null)
...{
if(!oSrc.checked)...{oSrc.click();}
}

for(i=oSrc.length-1;i>=0;i--)...{
if(!oSrc[i].checked)...{oSrc[i].click();}
}

}

}


functionunChkAll(oSrc)...{
oSrc
=eval(oSrc).rowId;
if(oSrc!=null)
...{
if(oSrc.length==null)
...{
if(oSrc.checked)...{oSrc.click();}
}

for(i=oSrc.length-1;i>=0;i--)...{
if(oSrc[i].checked)...{oSrc[i].click();}
}

}

}

页面部分(handle为页面的form的name值):

<inputtype="checkbox"name="all"value="checkbox"onclick="chkClick(this,handle)">
<tdalign="center"><inputtype="checkbox"name=rowIdvalue="<%=mn.getMobie_number()%>"></td>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics