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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 东哥

MongoVUE 错误:can't map file memory - mongo requires 64 bit build for larger datasets - 东哥 HTTP Header 属性列表 - 东哥 安装卸载Windows服务,修改windows服务执行路径! - 东哥 SQL 语句嵌套,自己记录下。 基于RBAC的权限设计模型 javascript中getElementsByName的问题 - 东哥 动态添加WEB控件,点控件获取动态添加的控件 数据库基本----SQL语句大全 使用Ajax时的十个常犯的错误 数据采集程序(网页小偷)点滴心得 WEB Service 下实现大数据量的传输 - 东哥 [转]将上传图片打上防伪图片水印并写入数据库 - 东哥 我奋斗了18年不是为了和你一起喝咖啡(转载) [转]社区好友列表利用率越高,社区越失败 - 东哥 很实用的一个图片上传得例子 [转帖]教程:使用WebService进行异步通信 - 东哥 如何用Javascript记录登陆次数 很酷实用的右键弹出菜单(Js+DVML) JavaScript如果文字过长,则将过长的部分变成省略号显示
三级连动JS数据库查询代码整理
东哥 · 2008-06-18 · via 博客园 - 东哥

数据库表设计

字段ClassID,ClassName,ClassType,ParentClassID

  • ClassID类别ID
  • ClassName类别名称
  • ClassType=1 顶级分类
  • ClassType=2一级分类
  • ClassType=3二级分类

ParentClassID父类ClassID,顶类的父类默认为0

脚本代码

<%
sql = "select * from Bs_ProductClass where ClassType=2 order by ClassID asc"
set rs = conn.execute(sql)
%>
<script language = "JavaScript">
 var onecount;
 onecount=0;
 subcat = new Array();
<%
count1 = 0
do while not rs.eof
%>
subcat[<%=count1%>] = new Array("<%= trim(rs("ClassName"))%>","<%= trim(rs("ParentClassID"))%>","<%= trim(rs("ClassID"))%>");
<%
count1 = count1 + 1
rs.movenext
loop
rs.close
set rs=nothing
%>
onecount=<%=count1%>;

function changelocation(ClassID1)
{
  document.myform.BigClassID.length = 0;
  var ClassID1=ClassID1;
  var i;
  var op1 = document.createElement("OPTION");
  document.myform.BigClassID.options[0] = new Option('==所属大类名称==',' ');
  for (i=0;i < onecount; i++)
  {
    if (subcat[i][1] == ClassID1)
    {
      op1= new Option(subcat[i][0], subcat[i][2]);
      document.myform.BigClassID.options.add(op1);
    }
  }

}
</script>

<%sql2 = "select * from Bs_ProductClass where ClassType=3 order by ClassID asc"
set rs2 = conn.execute(sql2)
%>
<script language = "JavaScript">
var onecount2;
onecount2=0;
subcat2 = new Array();
<%
count2 = 0
do while not rs2.eof
%>
subcat2[<%=count2%>] = new Array("<%= trim(rs2("ClassName"))%>","<%= trim(rs2("ParentClassID"))%>","<%= trim(rs2("ClassID"))%>");
<%
count2 = count2 + 1
rs2.movenext
loop
rs2.close
set rs2=nothing
%>
onecount2=<%=count2%>;

function changelocation2(ClassID2)
{
  document.myform.SmallClassID.length = 0;

  var ClassID2=ClassID2;
  var j;
  var op2 = document.createElement("OPTION");
  document.myform.SmallClassID.options[0] = new Option('==所属小类名称==',' ');
  for (j=0;j < onecount2; j++)
  {
    if (subcat2[j][1] == ClassID2)
    {
      op2 = new Option(subcat2[j][0], subcat2[j][2]);
      document.myform.SmallClassID.options.add(op2);
    }
  }

}
</script>

调用代码

<form name='myform'>

<select name="TopClassID" id="TopClassID" onChange="changelocation(document.myform.TopClassID.options.value)" size="1">
<option selected value="">请选择所属顶类</option>
<%

sql1 = "select * from Bs_ProductClass where ClassType=1 order by ClassID asc"
set rs1 = conn.Execute (sql1)
do while not rs1.eof
%>
<option value="<%=trim(rs1("ClassID"))%>"><%=trim(rs1("ClassName"))%></option>

<%
rs1.movenext
loop
rs1.close
set rs1 = nothing
conn.Close
set conn = nothing
%>
</select>
大类
<select name="BigClassID" id="BigClassID" onChange="changelocation2(document.myform.BigClassID.options[this.options.selectedIndex].value)">
<option selected value="">==所有大类==</option>
</select>
小类
<select name="SmallClassID" id="SmallClassID" size="1">
<option selected value="">==所有小类==</option>
</select>

</form>