大家帮我看看这段代码哪里错了好吗?我看了老半天没看出来!

frogJ 2004-08-05 08:06:59
就是 www.csdn.com.cn 上的 下拉联动的 代码.......我用了,有问题啊

ASP文件:
<%@ Language=VBScript %>
<%Option Explicit%>
<html>
<head>
<title>List</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
dim conn
dim rs
dim sql
dim count
dim rs1
dim sql1


set conn = server.CreateObject ("adodb.connection")
conn.Open "test","sa",""


sql = "select * from district order by locationid asc"
set rs = conn.execute(sql)
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("districtname"))%>","<%= trim(rs("locationid"))%>","<%= trim(rs("districtid"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
set rs=nothing
%>
onecount=<%=count%>;

function changelocation(locationid)
{
document.myform.smalllocation.length = 0;

var locationid=locationid;
var i;
document.myform.smalllocation.options[0] = new Option('====所有地区====',');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.smalllocation.options[document.myform.smalllocation.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}
</script>
</head>
<body>
<form name="myform" method="post">
<select name="biglocation" onChange="changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value)">
<%

sql1 = "select * from location order by locationname asc"
set rs1 = conn.Execute (sql1)
do while not rs1.eof
%>
<option value="<%=trim(rs1("locationid"))%>"><%=trim(rs1("locationname"))%></option>
<%
rs1.movenext
loop
rs1.close
set rs1 = nothing
conn.Close
set conn = nothing
%>
</select>
<select name="smalllocation">
<option selected value="">==所有地区==</option>
</select>
</form>
<script LANGUAGE="javascript">
changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value);
</script>
</body>
</html>

错误:

.............
onecount=5;

function changelocation(mainid)
{
document.myform.smalllocation.length = 0;

var mainid=mainid;
var i;
document.myform.smalllocation.options[0] = new Option('====所有地区====','');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == mainid)
{
document.myform.smalllocation.options[document.myform.smalllocation.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

}

//-->
</script>
</head>
<body>
<form name="myform" method="post">
<select name="biglocation" onChange="changelocation(document.myform.biglocation.options[document.myform.biglocation.selectedIndex].value)">
<font face="宋体" size=2>
<p>Microsoft VBScript 运行时错误</font> <font face="宋体" size=2>错误 '800a01a8'</font>
<p>
<font face="宋体" size=2>缺少对象: ''</font>
<p>
<font face="宋体" size=2>/esdn/2.asp</font><font face="宋体" size=2>,行 65</font>
...全文
151 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
frogJ 2004-08-05
  • 打赏
  • 举报
回复
哦~~~~

我终于自己把它搞定了!!

原来是

rs1.close
set rs1 = nothing
conn.close
set conn = nothing

中的 conn.close 写上就有
缺少对象: 'Provider=Microsoft.J'
这个错误........不知道怎么回事!

高手能给讲解一下吗?
frogJ 2004-08-05
  • 打赏
  • 举报
回复
真的吗?谢谢你啊,发一份给我好吗

sega.saturn3@163.com

我改了一顿 上面的代码结果这样了

缺少对象: 'Provider=Microsoft.J'

我晕,不明白这是什么错误!
zhaohh 2004-08-05
  • 打赏
  • 举报
回复
这个代码我又。要的话。给你发一份过去
frogJ 2004-08-05
  • 打赏
  • 举报
回复
他这里说的 错误 缺少对象 是什么?

缺少对象: ''
frogJ 2004-08-05
  • 打赏
  • 举报
回复
对啊,应该 是2个 ''

document.myform.smalllocation.options[0] = new Option('====所有地区====','');

这样吧,但是现在我改过来,也不对!
borlang 2004-08-05
  • 打赏
  • 举报
回复
把外围的双引号改为单引号,如:
"<%= trim(rs("districtname"))%>"改为
'<%= trim(rs("districtname"))%>'
还有这行是不是有错?
document.myform.smalllocation.options[0] = new Option('====所有地区====',');
frogJ 2004-08-05
  • 打赏
  • 举报
回复
好,我看看.........
  • 打赏
  • 举报
回复
呵呵,好像和我那个联动差不多的啊

http://computer.mblogger.cn/onion/posts/12370.aspx

你参考一下
frogJ 2004-08-05
  • 打赏
  • 举报
回复
多谢...........
xzhy80 2004-08-05
  • 打赏
  • 举报
回复
up
frogJ 2004-08-05
  • 打赏
  • 举报
回复
我把 数据库 字段名字改了,但没有错

我想应该是 js代码哪里错了.......死活看不出来,高手帮我啊

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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