您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

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

2024/3/28 16:46:32发布6次查看
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
%>
http://www.bkjia.com/phpjc/321638.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/321638.htmltecharticleindex.asp 页面代码 复制代码 代码如下: !--#include file=conn.asp -- % set cmd = conn.execute(select bigclassid,bigclassname from bigclass) tempid=cmd(bigclassid) %...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录