编写一个含二级目录的源码(Asp+JavaScript)
更新时间:2007年04月04日 00:00:00 作者:
********************** (一) 打开记录集,创建数组,把记录集的值赋给数组.
<%
Dim count
set Rs=server.createobject("adodb.recordset")
Sql = "select * from BookBoard order by ClassId desc"
Rs.open Sql,cn,1,1%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%count = 0
do while not Rs.eof %>
subcat[<%=count%>] = new Array("<%= trim(Rs("BoardName"))%>","<%= trim(Rs("ClassId"))%>","<%= trim(Rs("BoardId"))%>");
<%count = count + 1
Rs.movenext
loop
Rs.close%>
onecount=<%=count%>;
function changelocation(locationid)
{document.form1.BoardId.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{if (subcat[i][1] == locationid)
{document.form1.BoardId.options[document.form1.BoardId.length] = new Option(subcat[i][0], subcat[i][2]);
}}}
</script>
********************** (二) 显示分组,并编写列表框的OnChange事件.
<%set Rs=server.CreateObject("adodb.recordset")
Sql="select * from BookClass order by ClassId desc"
Rs.open Sql,cn,1,1
if Rs.eof and Rs.bof then
response.write "请先添加总类。"
response.end
else%>
<select name="ClassId" onChange="changelocation(document.form1.ClassId.options[document.form1.ClassId.selectedIndex].value)">
<option selected value="">==请选择大类==</option>
<% do until Rs.eof%>
<option value="<%=trim(Rs("ClassId"))%>"><%=trim(Rs("ClassName"))%></option>
<%Rs.movenext
loop
end if
Rs.close
set Rs = nothing%>
</select>
<select name="BoardId"><option selected value="">==请选择小类==</option>
</select>
<%
Dim count
set Rs=server.createobject("adodb.recordset")
Sql = "select * from BookBoard order by ClassId desc"
Rs.open Sql,cn,1,1%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%count = 0
do while not Rs.eof %>
subcat[<%=count%>] = new Array("<%= trim(Rs("BoardName"))%>","<%= trim(Rs("ClassId"))%>","<%= trim(Rs("BoardId"))%>");
<%count = count + 1
Rs.movenext
loop
Rs.close%>
onecount=<%=count%>;
function changelocation(locationid)
{document.form1.BoardId.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{if (subcat[i][1] == locationid)
{document.form1.BoardId.options[document.form1.BoardId.length] = new Option(subcat[i][0], subcat[i][2]);
}}}
</script>
********************** (二) 显示分组,并编写列表框的OnChange事件.
<%set Rs=server.CreateObject("adodb.recordset")
Sql="select * from BookClass order by ClassId desc"
Rs.open Sql,cn,1,1
if Rs.eof and Rs.bof then
response.write "请先添加总类。"
response.end
else%>
<select name="ClassId" onChange="changelocation(document.form1.ClassId.options[document.form1.ClassId.selectedIndex].value)">
<option selected value="">==请选择大类==</option>
<% do until Rs.eof%>
<option value="<%=trim(Rs("ClassId"))%>"><%=trim(Rs("ClassName"))%></option>
<%Rs.movenext
loop
end if
Rs.close
set Rs = nothing%>
</select>
<select name="BoardId"><option selected value="">==请选择小类==</option>
</select>
相关文章
UpdatePanel触发javascript脚本的方法附代码
UpdatePanel触发javascript脚本的方法附代码...2007-10-10ASP中使用FileSystemObject时提高性能的方法
在封装自己的FileSystemObject库的时候,测试的时候发现在文件夹或文件很多的时候,效率很低,显示一个文件夹需要2秒甚至更多,这让我很是奇怪,因为显示文件夹及文件信息的时候直接都是使用Folder及File对象的属性,这应该不会引起性能上的问题,但是事实却说明我的想法过于简单了。2008-05-05完美解决PJ的Cookies保存时限问题!可选择记录登陆时长!
完美解决PJ的Cookies保存时限问题!可选择记录登陆时长!...2007-02-02
最新评论