日期:2014-05-16 浏览次数:20549 次
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>Insert title here</title> <script type="text/javascript"> function selAll(obj) { var items = document.getElementsByTagName("input"); for(var i=0; i<items.length; i++) { if(items[i].type == "checkbox" && items[i].name == "checkSel") { items[i].checked = obj.checked; } } } function funCheck() { var flag = true; var items = document.getElementsByTagName("input"); for(var i=0; i<items.length; i++) { if(items[i].name == "checkSel") { if(!items[i].checked) { flag = false; break; } } } document.getElementById("cbSelectAll").checked = flag; } </script> </head> <body> <table border="1" align="center" style="margin-top: 80px; width:50%"> <tr> <th align="left" width="10%"> <input type="checkbox" id='cbSelectAll' onclick="selAll(this);"> </th> <th>标题</th> </tr> <tr> <td> <input type="checkbox" name='checkSel' onclick="funCheck()"> </td> <td>1</td> </tr> <tr> <td> <input type="checkbox" name='checkSel' onclick="funCheck()"> </td> <td>2</td> </tr> <tr> <td> <input type="checkbox" name='checkSel' onclick="funCheck()"> </td> <td>3</td> </tr> </table> </body> </html>?