[javascript]代码库
javascript :
<script type="text/javascript">
function checkAll(name)
{
var names=document.getElementsByName(name);
var len=names.length;
if(len>0)
{
var i=0;
for(i=0;i<len;i++)
names[i].checked=true;
}
}
//全不选
function checkAllNo(name)
{
var names=document.getElementsByName(name);
var len=names.length;
if(len>0)
{
var i=0;
for(i=0;i<len;i++)
names[i].checked=false;
}
}
</script>
html:
<input type="checkbox" name="checkbox" value="checkbox" onclick="if(this.checked==true) { checkAll('gonggaoid'); } else { checkAllNo('gonggaoid'); }"/>
全选</label></td>
<input type="checkbox" name="gonggaoid" value="abc" />