写了一个html的网页 嵌入了一些JavaScript的代码 但是实现不了功能呀 怎么回事呢 那些JavaScript代码 我就很郁闷了 那些JavaScri
写了一个html的网页 嵌入了一些JavaScript的代码 但是实现不了功能呀 怎么回事呢 那些JavaScript代码
我就很郁闷了 那些JavaScript代码在其他程序里是完全可以使用的呀 在这里却没有反映了 谢谢帮忙
<!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>
<SCRIPT LANGUAGE="JavaScript">
function selectAll(){
var checkObj = document.all("cheboxId");
for(var i = 0;i<checkObj.length;i++){
checkObj[i].checked = true;
}
}
function selectSome(){
var checkObj = document.all("cheboxId");
for(var i = 0;i<checkObj.length;i++){
if(checkObj[i].checked == true) checkObj[i].checked = false;
else checkObj[i].checked = true;
}
}
function switchAll() {
var checkObj = document.all("cheboxId");
for (var j = 1; j<checkObj.length; j++) {
box = eval("document.checkboxform.C" + j);
box.checked = !box.checked;
}
}
</script>
</head>
<body>
<table width="100%" border="1">
<tr>
<td width="8%" height="43" align="center">状态 </td>
<td width="15%" align="center">姓名</td>
<td width="10%" align="center">性别 </td>
<td width="18%" align="center">手机 </td>
<td width="16%" align="center">QQ </td>
<td width="16%" align="center">邮箱 </td>
<td width="16%" align="center">操作 </td>
</tr>
<tr>
<td><input type="checkbox" id="cheboxId" name="checkName" /> </td>
<td align="center">张三</td>
<td align="center">男</td>
<td align="center">13377006446</td>
<td align="center">984814676</td>
<td align="center">984814676@qq.com</td>
<td align="center">删除|修改</td>
</tr>
<td><input type="checkbox" id="cheboxId" name="checkName" /> </td>
<td align="center">张三</td>
<td align="center">男</td>
<td align="center">13377006446</td>
<td align="center">984814676</td>
<td align="center">984814676@qq.com</td>
<td align="center">删除|修改</td>
</tr>
</table>
<input type="button" value="全选" onClick="selectAll()"/>
<input type="button" value="反选" onClick="selectSome()"/>
<input type="button" value="选择转换" onClick="switchAll()"/>
<input type="button" value="全部删除" onClick="deleteAll()"/>
</body>
</html>
------解决方案--------------------
<!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=gbk" /><title>通讯录列表</title><SCRIPT LANGUAGE="JavaScript">function selectAll(){var checkObj = document.getElementsByName("checkName");for(var i = 0;i<checkObj.length;i++){checkObj[i].checked = true;}}function selectSome(){var checkObj = document.getElementsByName("checkName");for(var i = 0;i<checkObj.length;i++){if(checkObj[i].checked == true) checkObj[i].checked = false;else checkObj[i].checked = true;}}function switchAll() {var checkObj = document.getElementsByName("checkName"); for (var j = 1; j<checkObj.length; j++) { box = eval("document.checkboxform.C" + j); box.checked = !box.checked; }}</script></head><body><table width="100%" border="1"> <tr> <td width="8%" height="43" align="center">状态 </td> <td width="15%" align="center">姓名</td> <td width="10%" align="center">性别 </td> <td width="18%" align="center">手机 </td> <td width="16%" align="center">QQ </td> <td width="16%" align="center">邮箱 </td> <td width="16%" align="center">操作 </td> </tr> <tr> <td><input type="checkbox" id="cheboxId" name="checkName" /> </td> <td align="center">张三</td> <td align="center">男</td> <td align="center">13377006446</td> <td align="center">984814676</td> <td align="center">984814676@qq.com</td> <td align="center">删除|修改</td> </tr> <td><input type="checkbox" id="cheboxId" name="checkName" /> </td> <td align="center">张三</td> <td align="center">男</td> <td align="center">13377006446</td> <td align="center">984814676</td> <td align="center">984814676@qq.com</td> <td align="center">删除|修改</td> </tr> </table> <input type="button" value="全选" onClick="selectAll()"/> <input type="button" value="反选" onClick="selectSome()"/> <input type="button" value="选择转换" onClick="switchAll()"/> <input type="button" value="全部删除" onClick="deleteAll()"/></body></html>
[解决办法]
[code=JScript][function switchAll() {
var checkObj = document.all("cheboxId");
for (var j = 1; j<checkObj.length; j++) {
box = eval("document.checkboxform.C" + j);
box.checked = !box.checked;
}
}
/code]
经测试document.checkboxform.C你页面上根本就找不到document.checkboxform.C1这个。
deleteAll()这个方法没写。。
tip:
copy的时候不要一味的就是copy。。自己要明白它的意思。。