一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

基于asp+ajax和數據庫驅動的二級聯動菜單

index.ASP 頁面代碼
復制代碼 代碼如下:
<!--#include file="conn.ASP" -->
<%
set cmd = conn.execute("select bigclassid,bigclassname from bigclass")
tempid=cmd("bigclassid")
%>
<select name="menu" onChange="getsubcategory(this.value);">

<%
if not cmd.eof then
do while not cmd.eof
bigclassid= cmd("bigclassid")
bigclassname = cmd("bigclassname")
%>
<option value="<%=bigclassid%>"><%=bigclassname%></option>
<%
cmd.movenext
loop
end if
cmd.close
set cmd = nothing
%>
</select>
<div id="subclass">
<select name="submenu">

<%
set cxd = conn.execute("select * from smallclass where bigclassid=" & tempid)
if not cxd.eof then
do while not cxd.eof
smallclassid= cxd("smallclassid")
smallclassname = cxd("smallclassname")%>
<option value="<%=smallclassid%>"><%=smallclassname%></option>
<%
cxd.movenext
loop
cxd.close
set cxd = nothing
else
html = "<select name='smallclassid'><option value='0' selected>暫無小類</option></select>"
response.write html
end if
%>
</select>
</div>

ajax.js 代碼
復制代碼 代碼如下:
// JavaScript Document
function createxmlhttp()
{
xmlhttpobj = false;
try{
xmlhttpobj = new XMLHttpRequest;
}catch(e){
try{
xmlhttpobj=new ActiveXObject("MSXML2.XMLHTTP");
}catch(e2){
try{
xmlhttpobj=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e3){
xmlhttpobj = false;
}
}
}
return xmlhttpobj;
}

function getsubcategory(bigclassid){
if(bigclassid==0){
document.getElementById("subclass").innerHTML="<select name='smallclassid'><option value='0' selected>選擇二級分類</option></select>";
return;
};
var xmlhttpobj = createxmlhttp();
if(xmlhttpobj){//如果創建對象xmlhttpobj成功
xmlhttpobj.onreadystatechange=handle;
xmlhttpobj.open('get',"getsubcategory.ASP?bigclassid="+bigclassid+"&number="+Math.random(),true);//get方法 加個隨機數。


xmlhttpobj.send(null);
}
}

function handle(){//客戶端監控函數
//if(xmlhttpobj.readystate==4){//服務器處理請求完成
if(xmlhttpobj.status==200){
//alert('ok');
var html = xmlhttpobj.responseText;//獲得返回值
document.getElementById("subclass").innerHTML=html;
}else{
document.getElementById("subclass").innerHTML="對不起,您請求的頁面有問題...";
}
//}
//else{
//document.getElementById("subclass").innerHTML=xmlhttpobj.readystate;//服務器處理中
//}
//}

}

getsubcategory.ASP 代碼
復制代碼 代碼如下:
<%@language="vbscript" codepage="936"%>
<!--#include file="conn.ASP"-->
<%
response.charset="gb2312"
bigclassid=safe(request.querystring("bigclassid"))
if bigclassid<>"" then
set re=new regexp
re.ignorecase=true
re.global=false
re.pattern = "^[0-9]{1,3}$"
if not re.test(bigclassid) then
response.write "非法參數"
response.end
end if%>

<%on error resume next
set p = conn.execute("select * from smallclass where bigclassid=" & bigclassid)
if err then
err.clear
response.write "查詢出錯"
response.end
end if
if not p.eof then
html = "<select name='select2'>"&vbnewline
do while not p.eof
html = html&"<option value='"&p("smallclassid")&"'>"&p("smallclassname")&"</option>"&vbnewline
p.movenext
loop
html = html&"</select>"
else
html = "<select name='smallclassid'><option value='0' selected>暫無小類</option></select>"
end if
p.close
set p = nothing
conn.close
set conn = nothing
response.write html
html = ""
end if
%>

php技術基于asp+ajax和數據庫驅動的二級聯動菜單,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 网黄视频 | 精品精品国产自在久久高清 | 最新欧美精品一区二区三区 | 欧美视频色 | 精品视频在线免费观看 | 天天综合天天做天天综合 | 久久国产高清波多野结衣 | 麻豆一区二区三区四区 | 一本色道久久88加勒比—综合 | 大象焦伊人久久综合网色视 | 欧美日韩国产一区二区三区不卡 | 亚洲玖玖 | 一本一道dvd在线播放器 | 无码精品一区二区三区免费视频 | 狠狠穞老司机的福67194 | 国产精品久久久久影院色老大 | 亚洲欧美日韩第一页 | 玖玖国产精品 | 日日久 | 国产成人精视频在线观看免费 | 性夜影院爽黄e爽痛轻点www | 色综合图片二区150p | 国产乱码 | 国产久爱青草视频在线观看 | 日本乱理伦中文三区 | 国产午夜视频在线观看第四页 | 狠狠做久久深爱婷婷97动漫 | 1024国产基地永久免费 | 久久精品精品 | 日日噜噜噜夜夜爽爽狠狠视频 | 国产麻豆成91 | 五月丁香六月婷综合缴情在线 | 98香蕉草草视频在线精品看 | 78m成人亚洲| 日韩中文字幕精品一区在线 | 免费国产成高清人在线视频 | 国产成人精品亚洲日本在线 | 岬奈一区二区中文字幕 | 日本护士xxxxx18.19 | 天天狠天天透天天伊人 | 91精品一区二区三区在线观看 |