天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

基于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和數據庫驅動的二級聯動菜單,轉載需保留來源!

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

主站蜘蛛池模板: 美女全光末满18勿进 | 国产91网站在线观看免费 | 办公室的秘密2中文字幕 | 超嫩校花被灌醉在线观看 | 亚洲一区在线观看无码欧美 | 国产亚洲美女精品久久久2020 | 久久久精品日本一区二区三区 | 性刺激欧美三级在线现看中文 | 美女全光末满18勿进 | 无人区国产片 | 中文字幕视频在线免费观看 | 脔到她哭H粗话HWWW男男动漫 | xxxx18动漫| 好湿好紧水多AAAAA片秀人网 | 岛国片在线免费观看 | 蜜桃传媒一区二区亚洲AV | 扒开小处30p | 成人片免费看 | 2021精品国产综合久久 | 草草久久久亚洲AV成人片 | 亚洲第一色网 | 天天啪免费视频在线看 | 久9青青cao精品视频在线 | 含羞草影院AE在线观看 | 欧美激情一区二区三区视频 | 高挑人妻无奈张开腿 | 妹妹的第一次有点紧 | 色欲AV亚洲永久无码精品麻豆 | 中文字幕人成人乱码亚洲影视S | 中文字幕亚洲无线码在线 | 欧美高清视频www夜色资源网 | 日韩插啊免费视频在线观看 | 一个人免费完整在线观看影院 | 99国产在线视频有精品视频 | 国产欧美日韩综合精品一区二区 | 亚洲精品一二三区区别在哪 | 亚洲精品中文字幕一二三四区 | 亚洲成人日韩 | 东北成人社区 | 麻花传媒XK在线观看 | 精品伊人久久久 |