ajax二級聯動菜單

來源:互聯網
上載者:User

<!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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.