asp+ajax菜单,AJAX_基于asp+ajax和数据库驱动的二级联动菜单,index.asp 页面代码 复制代码 代 - phpStudy...

 2023-09-15 阅读 15 评论 0

摘要:基于asp+ajax和数据库驱动的二级联动菜单index.asp 页面代码ajax调用jsp。复制代码 代码如下:set cmd = conn.execute("select bigclassid,bigclassname from bigclass")tempid=cmd("bigclassid")mvc会用到ajax吗?%>if not cmd.eof thendo wh

基于asp+ajax和数据库驱动的二级联动菜单

index.asp 页面代码

ajax调用jsp。复制代码 代码如下:

set cmd = conn.execute("select bigclassid,bigclassname from bigclass")

tempid=cmd("bigclassid")

mvc会用到ajax吗?%>

if not cmd.eof then

do while not cmd.eof

ajax异步调用数据库内容,bigclassid= cmd("bigclassid")

bigclassname = cmd("bigclassname")

%>

cmd.movenext

loop

end if

cmd.close

set cmd = nothing

%>

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")%>

cxd.movenext

loop

cxd.close

set cxd = nothing

else

html = "暂无小类"

response.write html

end if

%>

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="选择二级分类";

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 代码

复制代码 代码如下:

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

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 = ""&vbnewline

do while not p.eof

html = html&""&p("smallclassname")&""&vbnewline

p.movenext

loop

html = html&""

else

html = "暂无小类"

end if

p.close

set p = nothing

conn.close

set conn = nothing

response.write html

html = ""

end if

%>相关阅读:

关于B/S判断浏览器断开的问题讨论

HTML5还有多远 开发者的机会

asp下实现格式化文件大小以MB显示的函数

用JavaScript实现全局替换,解决$等特殊符号的难题[

搜索和替换文件或目录的一个好类--很实用

asp 空值测试判断函数

基于Jquery与WebMethod投票功能实现代码

PHP学习宝典-第六章(续篇)

Linux操作系统最强大的功能是什么

点选TOP后并不是直接跳到页顶的,而是滚动上去的

math.vbs 自然数n的n次方的的和或积的级数

javascript dragable的Move对象

attachEvent的使用方法与传递参数[IE|firefox]

用javascript实现的仿Flash广告图片轮换效果

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/5/61688.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息