日期:2014-05-16 浏览次数:20410 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <script type="text/javascript"> function allSelect() { var username = document.getElementsByName("usernames"); var state = document.getElementById("allselectbox").checked; var length = document.getElementsByName("usernames").length; if (length) { for (var i = 0; i < length; i++) { username[i].checked = state; } } else { username.checked = state; } } function selectAll() { var length = document.getElementsByName("usernames").length; var username = document.getElementsByName("usernames"); for (var i = 0,count = 0; i < length; i++) { if (username[i].checked == true) { count++; if (count == length) { document.getElementById("allselectbox").checked = true; } else { document.getElementById("allselectbox").checked = false; } } if (count == 0) { document.getElementById("allselectbox").checked = username[i].checked; } } } </script> </head> <body> <table> <tr> <td bgcolor="f5f5f5"> <div align="center"><input type="checkbox" name="usernames" value="${entry.username}" onclick="selectAll()"> </div> </td> <td bgcolor="f5f5f5"> <div align="center">Name1</div> </td> </tr> <tr> <td bgcolor="f5f5f5"> <div align="center"><input type="checkbox" name="usernames" value="${entry.username}" onclick="selectAll()"> </div> </td> <td bgcolor="f5f5f5"> <div align="center">Name2</div> </td> </tr> <tr> <td bgcolor="f5f5f5"> <div align="center"><input type="checkbox" name="usernames" value="${entry.username}" onclick="selectAll()"> </div> </td> <td bgcolor="f5f5f5"> <div align="center">Name3</div> </td> </tr> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td width="10%"><input type="checkbox" onclick="javascript:allSelect()" id="allselectbox">SelectAll/None</td> </tr> </table> </body> </html>