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

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

主站蜘蛛池模板: 伊人国产在线观看 | 色橹橹欧美在线观看视频高清 | 午夜福利理论片在线播放 | 美女内射视频WWW网站午夜 | 日本久久精品免视看国产成人 | 学校女性奴sm训练调教 | 品色堂主页 | 国产精品97久久AV麻豆 | 黃色带三级a级 | AV午夜午夜快憣免费观看 | 古代又黄又肉到湿的爽文 | 丝瓜视频樱桃视频在线观看免费 | 中文字幕不卡免费高清视频 | 青青青国产依人精品视频 | 九九热在线观看 | 暖暖视频大全免费观看 | 浪货嗯啊趴下NP粗口黄暴 | 韩国伦理片2018在线播放免费观看 | 女的把腿张开男的往里面插 | 欲香欲色天天影视大全 | 老师洗澡让我吃她胸的视频 | 春水福利app导航 | 无限资源在线观看8 | 麻豆精品传媒2021网站入口 | 国产亚洲日韩在线播放不卡 | 花蝴蝶高清影视视频在线播放 | 国产精品av| 看了n遍舍不得删的黄文 | 中文字幕在线观看 | 吉吉影音先锋av资源网 | 国产曰批试看免费视频播放免费 | 午夜欧洲亚洲AV永久无码精品 | 共妻肉多荤文高h一女n男 | 日韩精品亚洲专区在线电影不卡 | 99国产强伦姧在线看RAPE | 免费看 a一级毛片 免费久久狼人香蕉网 | 老太脱裤子让老头玩xxxxx | 粉嫩自拍 偷拍 亚洲 | 免费无码国产欧美久久18 | 国产精品一国产精品免费 | 晓雪老师我要进你里面好爽 |