永发信息网

请帮忙找下这段JS代码的错误

答案:2  悬赏:70  手机版
解决时间 2021-07-25 12:55
  • 提问者网友:绫月
  • 2021-07-25 09:14

<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function checkAll(boolValue){
var allCheckBoxs=document.getElementsByName("cb");
for(var i=0;i<allCheckBoxs.length;i++){
allCheckBoxs[i].checkd=boolValue;
}
}
</script>
</head>

<body>
<img src="Lesson03/上机作业/作业3/images/top.jpg" width="1004" height="173" /><br />
<table width="979" height="207" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="164"><div align="center">全选/取消
<input type="checkbox" name="acb" id="acb" onclick="checkAll(boolValue)/>
</div>
</label></td>
<td><img src="lesson03/上机作业/作业3/images/1.jpg" width="818" height="93" />
</div>
<label>
<div align="center"></td>
<td width="815"><img src="Lesson03/上机作业/作业3/images/menu2.jpg" width="763" height="28" /></td>
</tr>
<tr>
<td><div align="center">
<input type="checkbox" name="cb" id="checkbox2" />
</div></td>
<td><img src="Lesson03/上机作业/作业3/images/2.JPG" width="816" height="87" /></td>
</tr>
<tr>
<td><div align="center">
<input type="checkbox" name="cb" id="checkbox3" />
</div></td>
<td><img src="Lesson03/上机作业/作业3/images/3.JPG" width="822" height="84" /></td>
</tr>
<tr>
<td><div align="center">
<input type="checkbox" name="cb" id="checkbox4" />
</div></td>
<td><img src="Lesson03/上机作业/作业3/images/4.JPG" width="824" height="87" /></td>
</tr>
<tr>
<td><div align="center">
<input type="checkbox" name="cb" id="checkbox5" />
</div></td>
<td><img src="Lesson03/上机作业/作业3/images/5.JPG" width="909" height="88" /></td>
</tr>
</table>
<br />
<img src="Lesson03/上机作业/作业3/images/menu.jpg" width="957" height="32" />
<blockquote>
<p><br />
</p>
</blockquote>
</body>
</html>

最佳答案
  • 五星知识达人网友:鱼芗
  • 2021-07-25 10:39
这里的name=“cb"吧应该,第三行
全部回答
  • 1楼网友:一袍清酒付
  • 2021-07-25 11:36

onclick="checkAll(this.checked);"//这行应该这样写.

allCheckBoxs[i].checkd=boolValue;//应该是checked

//--------------------------------完整代码

<html xmlns=" http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script language="javascript"> function checkAll(boolValue) { var allCheckBoxs=document.getElementsByName("cb"); for(var i=0;i<allCheckBoxs.length;i++){ allCheckBoxs[i].checked=boolValue; } } </script> </head>

<body> <img src="Lesson03/上机作业/作业3/images/top.jpg" width="1004" height="173" /><br /> <table width="979" height="207" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="164"><div align="center">全选/取消 <input type="checkbox" name="acb" id="acb" onclick="checkAll(this.checked);"/> </div> </label></td> <td><img src="lesson03/上机作业/作业3/images/1.jpg" width="818" height="93" /> </div> <label> <div align="center"></td> <td width="815"><img src="Lesson03/上机作业/作业3/images/menu2.jpg" width="763" height="28" /></td> </tr> <tr> <td><div align="center"> <input type="checkbox" name="cb" id="checkbox2" /> </div></td> <td><img src="Lesson03/上机作业/作业3/images/2.JPG" width="816" height="87" /></td> </tr> <tr> <td><div align="center"> <input type="checkbox" name="cb" id="checkbox3" /> </div></td> <td><img src="Lesson03/上机作业/作业3/images/3.JPG" width="822" height="84" /></td> </tr> <tr> <td><div align="center"> <input type="checkbox" name="cb" id="checkbox4" /> </div></td> <td><img src="Lesson03/上机作业/作业3/images/4.JPG" width="824" height="87" /></td> </tr> <tr> <td><div align="center"> <input type="checkbox" name="cb" id="checkbox5" /> </div></td> <td><img src="Lesson03/上机作业/作业3/images/5.JPG" width="909" height="88" /></td> </tr> </table> <br /> <img src="Lesson03/上机作业/作业3/images/menu.jpg" width="957" height="32" /> <blockquote> <p><br /> </p> </blockquote> </body> </html>

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯