日期:2014-05-18  浏览次数:20640 次

按钮实现checkbox框全选(在线等待)
我的JSP页面是通过点击一个按钮弹出来的!
这个JSP页面全是checkbox选择框
现在我想加一个按钮实现一键全选!
请教高手指点!

----------------在线等待

------解决方案--------------------
给checkbox取个相同的名字然后
for(var i = 0 ;i < name.length; i++){
name[i].checked = true;
}
试试
------解决方案--------------------
html:
<td id = "selectButton " class= "coolButton " title= "全选/全取消 " valign= "middle " onclick= "selectAll() " nowrap>
&nbsp;全选/全取消&nbsp;
</td>

<input name= "checkbox " type= "checkbox " style= "align: center; "/>


javascript:
function selectAll()
{
var checkbox = document.getElementsByTagName( "input ");
for (var i=0; i <checkbox.length; i++)
if (checkbox[i].type == "checkbox ") checkbox[i].checked =!checkbox[i].checked;
}
------解决方案--------------------
接分