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

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

index.asp 页面代码

复制代码 代码如下:

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

tempid=cmd("bigclassid")

%>

if not cmd.eof then

do while not cmd.eof

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广告图片轮换效果

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值