document.myform.smallclassid.option.7不是对象?

tyy_yun 2002-10-16 04:03:52
function changelocation(locationid)
{
document.myform.smallclassid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid) //大类id匹配
{
document.myform.smallclassid.options[document.myform.smallclassid.length] = new Option(subcat[i][0], subcat[i][2]);
alert(document.myform.smallclassid.length)
<% if cstr(scid)=cstr(request("id")) then
%>
document.myform.smallclassid.options[<%=scid%>].selected = true;
<% end if %>
}
}
}
</script>
<body onload=changelocation(<%=request("bigclassid")%>)>

document.myform.smallclassid.option.7不是对象?
各位帮我看看哪错了
...全文
51 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2002-10-17
  • 打赏
  • 举报
回复
出现这种错误的原因就是:
假设:
你的option一共有7个,你却用selectName.options[7]来访问,就会造成这样的错误。
7个option,你可以用
selectName.options[i]
i=0-6来访问
tyy_yun 2002-10-16
  • 打赏
  • 举报
回复
document.myform.smallclassid.options.length=1
yonghengdizhen 2002-10-16
  • 打赏
  • 举报
回复
document.myform.smallclassid.options[<%=scid%>]
检查你的document.myform.smallclassid.options.length
看是否=8
因为options是基于零的索引
tyy_yun 2002-10-16
  • 打赏
  • 举报
回复
怎么不可以啊
可以用啊
document.myform.smallclassid.option.7就是js里的
document.myform.smallclassid.options[<%=scid%>]啊
潇洒 2002-10-16
  • 打赏
  • 举报
回复
晕........js 不能直接用 asp 的值!!!!!!!!!
tyy_yun 2002-10-16
  • 打赏
  • 举报
回复
在javascript前的asp代码里
ssm1226 2002-10-16
  • 打赏
  • 举报
回复
onecount是什么东西?
你在哪获取的
tyy_yun 2002-10-16
  • 打赏
  • 举报
回复
就是smallclassid的记录数
孟子E章 2002-10-16
  • 打赏
  • 举报
回复
超过的你的option的数目了吧
onecount是多少?

87,996

社区成员

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

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