惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - scgw

Android隐藏状态栏、导航栏 Android监听返回键、Home键+再按一次返回键退出应用 PDFMate PDF Converter Pro [转]远程唤醒技术在运维中的应用 [转]Raspberry Pi树莓派无线网卡配置[多重方法备选] 如何查看天猫产品的历史最低价? 空间不支持openssl解决办法 图片轮播器bcastr4.swf“&”符号的问题 aspcms,2.x以上版本,保护栏目不可删除处理方法 JS实时数据运算 Access数据库中Sum函数返回空值(Null)时如何设置为0 asp检测数字类型函数 MVC:从客户端中检测到有潜在危险的 Request.Form 值 的解决方法 WIN8系统安装软件时提示"扩展属性不一致"的解决方法 免费的网络扫描器-Advanced IP Scanner asp获取文件名和扩展名的函数代码 ACCESS自动编号清零 Excel命名区域的创建、修改、删除、命名 生命中十种爱的方法
[转]asp三级select菜单联动(加数据库)
scgw · 2014-04-06 · via 博客园 - scgw

'数据库结构
'类别1表名称:a 字段:ID,Name 说明:ID为主键是类别1的ID值,Name为类别1的名称
'类别2表名称:aa 字段:ID,aID,Name 说明:ID为主键是类别2的ID值,aID为所属类别1的ID值,Name为类别2的名称
'类别3表名称:aaa 字段:ID,aID,aaID,Name 说明:ID为主键是类别3的ID值,aID为所属类别1的ID值,aaID为所属类别2的ID值,Name为类别3的名称
程序代码 程序代码<!-- 三级联动菜单 开始 -->
<script language="JavaScript">
<!--
<%
'二级数据保存到数组
Dim count2,rsClass2,sqlClass2
set rsClass2=server.createobject("adodb.recordset")
sqlClass2="select * from aa" 
rsClass2.open sqlClass2,conn,1,1
%>
var subval2 = new Array();
//数组结构:一级根值,二级根值,二级显示值
<%
count2 = 0
do while not rsClass2.eof
%>
subval2[<%=count2%>] = new Array('<%=rsClass2("aID")%>','<%=rsClass2("ID")%>','<%=rsClass2("Name")%>')
<%
count2 = count2 + 1
rsClass2.movenext
loop
rsClass2.close
%>
<%
'三级数据保存到数组
Dim count3,rsClass3,sqlClass3
set rsClass3=server.createobject("adodb.recordset")
sqlClass3="select * from aaa" 
rsClass3.open sqlClass3,conn,1,1
%>
var subval3 = new Array();
//数组结构:二级根值,三级根值,三级显示值
<%
count3 = 0
do while not rsClass3.eof
%>
subval3[<%=count3%>] = new Array('<%=rsClass3("aaID")%>','<%=rsClass3("ID")%>','<%=rsClass3("Name")%>')
<%
count3 = count3 + 1
rsClass3.movenext
loop
rsClass3.close
%>
function changeselect1(locationid)
{
document.form1.s2.length = 0;
document.form1.s2.options[0] = new Option('==请选择类别==','');
document.form1.s3.length = 0;
document.form1.s3.options[0] = new Option('==请选择专题==','');
for (i=0; i<subval2.length; i++)
{
if (subval2[i][0] == locationid)
{document.form1.s2.options[document.form1.s2.length] = new Option(subval2[i][2],subval2[i][1]);}
}
}
function changeselect2(locationid)
{
document.form1.s3.length = 0;
document.form1.s3.options[0] = new Option('==请选择专题==','');
for (i=0; i<subval3.length; i++)
{
if (subval3[i][0] == locationid)
{document.form1.s3.options[document.form1.s3.length] = new Option(subval3[i][2],subval3[i][1]);}
}
}
//-->
</script>
<form name="form1" method="post" action="test1.asp">
三级联动:
<%
Dim count1,rsClass1,sqlClass1
set rsClass1=server.createobject("adodb.recordset")
sqlClass1="select * from a" 
rsClass1.open sqlClass1,conn,1,1
%>
<select name="s1" onChange="changeselect1(this.value)">
<option>==请选择频道==</option>
<%
count1 = 0
do while not rsClass1.eof
response.write"<option value="&rsClass1("ID")&">"&rsClass1("Name")&"</option>"
count1 = count1 + 1
rsClass1.movenext
loop
rsClass1.close
%>
</select>
<select name="s2" onChange="changeselect2(this.value)"> 
<option>==请选择类别==</option>
</select>
<select name="s3"> 
<option>==请选择专题==</option>
</select>
<input type="submit" name="Submit" value="提交"></form>
<!-- 三级联动菜单 结束 -->

=====test1.asp 你可以测试下,接收到的都是类别的ID值====
 程序代码<%
response.write"1:"&Request.form("s1")&"<BR>"
response.write"2:"&Request.form("s2")&"<BR>"
response.write"3:"&Request.form("s3")&"<BR>"
%>