<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>ajax二級聯動菜單</title>
<script language="網頁特效">
/*--------------------------------------------------------------------
*
*建立一個xmlhttp執行個體
*return object 成功建立返回一個xmlhttp對象執行個體,否則返回false
*
*--------------------------------------------------------------------
*/
function createajax(){
var xmlhttp;
try
{
xmlhttp = new activexobject("microsoft.xmlhttp"); //ie的建立方式
}
catch(e)
{
try
{
xmlhttp = new xmlhttprequest(); //ff等瀏覽器的建立方式
}
catch(e)
{
xmlhttp = false; //建立失敗,返回false
}
}
return xmlhttp; //返回xmlhttp執行個體
}
function getoid(ids,sid){
var xmlhttp = createajax();
var urllink = 'list10.asp?oid='+ids+'&sid='+sid+'&n='+math.random()+'';
if(xmlhttp){
xmlhttp.open('get',urllink,true);
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readystate == 4){ //用戶端完成請求
if(xmlhttp.status == 200){ //服務端完成處理並返回資料
var responsetext = xmlhttp.responsetext;
if(responsetext == ""){ //service返回了錯誤資訊
//alert("yes");
smclass.innerhtml = responsetext;
}else{
//alert("no");
smclass.innerhtml = responsetext;
}
}else{
smclass.innerhtml = '伺服器返回異常...';//伺服器出現異常
}
}else{
smclass.innerhtml = '正在載入資料...';//請求未完成時的提示資訊
}
}
xmlhttp.send(null);//向伺服器發送請求
}else{
smclass.innerhtml = '您的瀏覽器不支援或未啟用 xmlhttp!';//建立未成功
}
}
</script>
</head>
<body>
</body>
</html>
<!--#include file="conn.asp" -->
<%
response.charset = "gb2312"
dim outstr,ors,osql
oid = request("oid")
sid = request("sid")
if (oid = "" or isnull(oid)) then
outstr = ""
else
outstr = "<select name=""smid"">"
outstr = outstr &"<option value=""0"">不指定小類</option>"
osql = "select id,otitle,opx,oid from news_cls where oid = "&oid&" "
osql = osql &" order by opx asc"
set ors = conn.execute(osql)
if (ors.eof and ors.bof) then
outstr = outstr &"<option value=""0"">暫無小類</option>"
else
do while not ors.eof
if trim(sid) = trim(ors(0)) then
outstr = outstr &"<option value="""&ors(0)&""" selected>"&ors(1)&"</option>"
else
outstr = outstr &"<option value="""&ors(0)&""">"&ors(1)&"</option>"
end if
ors.movenext
loop
end if
outstr = outstr &"</select>"
set ors = nothing
end if
response.write(outstr)
''資料庫教程串連檔案
dim mdb,conn,connstr
mdb="database/adsl.mdb"
set conn = server.createobject("adodb.connection")
connstr = "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath(mdb) & " "
conn.open connstr
sub closeconn()
if isobject(conn) then
conn.close
set conn = nothing
end if
end sub
''表結構
id otitle oid opath ofile opx
1 雲南線路 0 yunnanxianlu index.shtml 1
2 雲南省旅遊 1 yunnanshenglvyou index.shtml 2
3 國內旅遊 1 guonalvyou index.shtml 1
4 出境旅遊 1 chujinglvyou index.shtml 3
5 走進雲南 0 zoujinyunnan index.shtml 2
6 雲南土特名產 5 yunnantutemingchan index.shtml 1
7 雲南少數民族 5 yunnanshaoshuminzu index.shtml 2
8 雲南十八怪查 5 yunnanshibaguaicha index.shtml 3
%>
源碼下載地址
http://down.111cn.net/down/code/asp/2010/0927/20955.html