function changeb(b)
{
if (b==0)
{
return false
}
<%
pid=clong(b)
sql="select id from hw where fatherid="&pid
rs1.open sql,conn,1,1
rs1.movelast
%>
document.form1.shpID.value=<%=rs1("ID")+1%>
<%
rs1.close
%>
}
以上为onchange调用的函数,页面一片空白
如果把sql改成
sql="select id from stationery where fatherid=2503001"
则显示正常
请问为什么?
你没有搞清楚ASP的原理!
ASP代码是在服务器运行后解析成HTML语言了再发送到客户端的。
JAVASCRIPT就是单纯在客户端运行。
所以先运行的是ASP代码,后运行的是JAVASCRIPT。
你这段代码因为在服务器运行的时候,pid=clong(b)这个b是没有经过定义的,并且也没有赋任何值,你用了clong函数后就变成0了,所以你查询数据库得出来的就是:
sql="select id from hw where fatherid=0"
的结果!!
所以,页面就一片空白了!
楼上说得对。<% %>中的内容是先运行的。你的问题可以有多种方法解决。
比如:
1、将b传给另一个ASP,使之变为服务器变量。
2、预先读出数据库的数据,生成客户端Script中的数组,在客户端的VBScript或JAVAScript中使用。
或者,你可以这样改:
<%
pid=clong(b)
sql="select id from hw where fatherid="&pid
response.write sql
rs1.open sql,conn,1,1
rs1.movelast
%>
然后查看源代码,看看sql语句是否有错。
你可以用这个.
通过value=index.asp?order=
传值,用request("")取得值后,改变SQL语句.
从而进行排列.
//不知道你是不是要这种 :)
index.asp
<%
order=request("order")
dim sql
dim rs
set rs = server.createobject("adodb.recordset")
sql = "select * from hw where url<> order by "&order&" desc"
rs.open sql,conn,1,1
..........
%>
<select onchange="if(this.options[this.selectedIndex].value!=){location=this.options[this.selectedIndex].value;}">
<option selected>开发排序选择</option>
<option value=index.asp?order=id>按加入时间排序</option>
<option value=index.asp?order=hit>按下载次数排序</option>
<option value=index.asp?order=softname>按软件名称排序</option>
<option value=index.asp?order=title>按开发标题排序</option>
</select>