GridView中CheckBox实现全选与反选的Javascript脚本
呵呵!记一段脚本放这里,在之前的项目中有用到。
代码如下:
代码如下:
<script type="text/javascript">
function chkSelectAll(spanckb)
{
var thebox = spanckb;
oState = thebox.checked;
oItem = thebox.form.elements;
for(i=0;i<oItem.length;i++)
{
if(oItem[i].type=="checkbox" & oItem[i].id!=thebox.id)
{
if(oItem[i].checked!=oState)
oItem[i].click();
}
}
}
</script>
function chkSelectAll(spanckb)
{
var thebox = spanckb;
oState = thebox.checked;
oItem = thebox.form.elements;
for(i=0;i<oItem.length;i++)
{
if(oItem[i].type=="checkbox" & oItem[i].id!=thebox.id)
{
if(oItem[i].checked!=oState)
oItem[i].click();
}
}
}
</script>