在线等:下面代码中的两个函数为什么不能执行的?

hooklee 2002-12-30 12:33:22
在另外一个文件中可以正常运行,把它拷贝到一个新文件中,改了一下form的名字什么的就不行了。真是邪门了。

<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<script language="JavaScript">
function clickall(v)
{
var f=document.forms["Decoy"];
alert(f.elements.length);
for (i=1;i<f.elements.length;i++)
f.elements[i].checked=v;
document.forms["Decoy"].elements["ClearAll"].checked=0;
}
function clearall()
{
var f=document.forms["Decoy"];
for (i=1;i<f.elements.length;i++)
f.elements[i].checked=0;
document.forms["Decoy"].elements["ClickAll"].checked=0;
}
}
</script>

<form name="Decoy" method="post" action="decoy_pic.asp">
<input type='checkbox' name='picture1' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture2' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture1' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture2' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture1' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture2' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture1' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture2' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture1' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture2' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture1' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture2' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture1' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture2' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture1' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture2' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture1' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture2' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture1' value='true' title='Please click me to select the above picture as a decoy-picture!'>
<input type='checkbox' name='picture2' value='true' title='Please click me to select the above picture as a decoy-picture!'><br>
<input type="radio" name="ClickAll" OnClick="clickall(this.checked)"> Select All Pictures as Decoys
<input type="radio" name="ClearAll" OnClick="clearall()"> Clear All Pictures
</form>

</body>
</html>
...全文
39 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
hooklee 2002-12-31
  • 打赏
  • 举报
回复
谢谢大家,结贴拉。
adu_neu 2002-12-30
  • 打赏
  • 举报
回复
VisualInterdev
孟子E章 2002-12-30
  • 打赏
  • 举报
回复
Venkman, the new JavaScript Debugger
http://devedge.netscape.com/viewsource/2002/venkman/01/

vs也不错
lbd8848 2002-12-30
  • 打赏
  • 举报
回复
说错了,不在iis中,它是windows的一个组件,在添加删除程序中
lbd8848 2002-12-30
  • 打赏
  • 举报
回复
安装脚本调试器,在iis中
hooklee 2002-12-30
  • 打赏
  • 举报
回复
太分特了。。。居然是这样的错误,检查了好久也没看见。。。

Javascript有什么调试的方法不?
lbd8848 2002-12-30
  • 打赏
  • 举报
回复
...
f.elements[i].checked=0;
document.forms["Decoy"].elements["ClickAll"].checked=0;
}
}
</script>
去掉这里的最后一个"}"
ppdy 2002-12-30
  • 打赏
  • 举报
回复
樓上說的對.
利而不害 2002-12-30
  • 打赏
  • 举报
回复
写程序要有良好的写作格式,该缩进的缩进,该空行的空行。如果你像这样写,应该很快就能发现这个花括号不匹配的错误。
<script language="JavaScript">
function clickall(v) {
var f=document.forms["Decoy"];

for (i=0;i<f.elements.length;i++)
f.elements[i].checked=v;
document.forms["Decoy"].elements["ClearAll"].checked=0;
}
function clearall() {
var f=document.forms["Decoy"];

for (i=0;i<f.elements.length;i++)
f.elements[i].checked=0;
document.forms["Decoy"].elements["ClickAll"].checked=0;
}
</script>
江南昆虫 2002-12-30
  • 打赏
  • 举报
回复
如果你真是想选中全部的话,for应该从0开始!

for (i=0;i<f.elements.length;i++)

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧