日期:2014-05-16 浏览次数:20383 次
<FORM id=weaver name=frmmain method=post> <table class=Form> <tr class=field> <td colspan=2 align=left> <input type="checkbox" name="m12" value="M12" onclick="checkMain('12')"> <b> 系统使用 </b> </td> </tr> <tr class="field"> <td> </td> <td> <input type="checkbox" name="s12" value="S27" onclick="checkSub('12')"> 系统使用规范 </td> </tr> <tr class="field"> <td> </td> <td> <input type="checkbox" name="s12" value="S28" onclick="checkSub('12')"> 系统功能介绍 </td> </tr> </table> <table class=Form> <tr class=field> <td colspan=2 align=left> <input type="checkbox" name="m7" value="M7" onclick="checkMain('7')"> <b> 会议资料 </b> </td> </tr> <tr class="field"> <td> </td> <td> <input type="checkbox" name="s7" value="S12" onclick="checkSub('7')"> 会议资料 </td> </tr> </table> </form> <script> function checkMain(id) { len = document.frmmain.elements.length; var mainchecked = document.all("m" + id).checked; var i = 0; for (i = 0; i < len; i++) { if (document.frmmain.elements[i].name == 's' + id) { document.frmmain.elements[i].checked = mainchecked; } } }; function checkSub(id) { len = document.frmmain.elements.length; var i = 0; for (i = 0; i < len; i++) { if (document.frmmain.elements[i].name == 's' + id) { if (document.frmmain.elements[i].checked) { document.all("m" + id).checked = true; return; } } } document.all("m" + id).checked = false; }; </script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> ul { list-style:none; } </style> <script type="text/javascript"> window.onload = function() { var obj = document.getElementById('demo').getElementsByTagName('input'); for (var i = 0; i < obj.length; i ++) { obj[i].onclick = function() { //查找并选择/取消选择所有子项 var childrenObj = this.parentNode.getElementsByTagName('ul'); if (childrenObj.length > 0) { for (var j = 0; j < childrenObj.length; j ++) { var o = childrenObj[j].getElementsByTagName('input'); for