关闭

2006-05-18 Javascript + Asp VBScript +Access 三级联列表框 By Stabx

标签: vbscriptjavascriptaccessaspstringfunction
1346人阅读 评论(0) 收藏 举报
分类:
标题: 2006-05-18 Javascript + Asp VBScript +Access 三级联列表框 By Stabx
正文:

QUOTE:

作用说明:
选择一级类别, 关联显示隶属二级类别, 再关联显示隶属于二级类别的三级类别

 


CODE:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/conn.asp" -->
<!--#include virtual="include/globalabbr.asp"-->
<!--#include virtual="func/func-glossary.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' subject : Javascript + ASP VBScript + Access 三级联列表框 By Stabx
'
' writer : Stabx<shawl.qiu@gmail.com>
'
' blog : http://blog.csdn.net/btbtd / http://btbtd.exblog.jp/
'
' blog/site : Phoenix.GI - P.GI / / 绿色学院 - Green Institute
'
' date : 2006-05-18
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'连接数据库表
sqlsupercat= "select * from ctglossarysupercat"
sqlsubcat= "SELECT a.*, b.*, c.* FROM (ctglossarysubcat AS a left JOIN ctglossarysubsubcat as c on a.gscid=c.gscid ) left JOIN ctglossarysupercat AS b ON a.gcid = b.gcid"
sqlsubsubcat= "select * from ctglossarysubsubcat"

set rs=server.CreateObject("adodb.recordset") '创建 rs 数据查询
%>
<% rs.open sqlsubcat,MM_conn_string,1 %>
<script LANGUAGE="JAVASCRIPT">
var onecount; //定义子类计数
onecount=0; //设置子类计数默认值为0
subcat = new Array(); //定义显示子类数组
<% count = 0
do while not rs.eof %>
subcat[<%=count%>] = new Array("<%=rs("gscat")%>","<%=rs("a.gcid")%>","<%=rs("a.gscid")%>","<%=rs("c.gcid")%>","<%=rs("c.gscid")%>","<%=rs("gsscat")%>");
<% count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>; //子类条目总数
function changelocation(locationid)
{
document.catform.subid.length = 0;
document.catform.subsubid.length = 0;

var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.catform.subid.options[document.catform.subid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}

for (i=0;i < onecount; i++)
{
if (subcat[i][4]==document.catform.subid.options.value)
{
document.catform.subsubid.options[document.catform.subsubid.length] = new Option(subcat[i][5], subcat[i][3]);
}
}
}
</script>
<% rs.open sqlsubsubcat,MM_conn_string,1 %>
<script LANGUAGE="JAVASCRIPT">
var osubnecount; //定义子类计数
subonecount=0; //设置子类计数默认值为0
subsubcat = new Array(); //定义显示子类数组
<% subcount = 0
do while not rs.eof %>
subsubcat[<%=subcount%>] = new Array("<%=rs("gsscat")%>","<%=rs("gscid")%>","<%=rs("gsscid")%>");
<% subcount = subcount + 1
rs.movenext
loop
rs.close
%>
subonecount=<%=subcount%>; //子类条目总数
function subchangelocation(sublocationid)
{
document.catform.subsubid.length = 0;

var sublocationid=sublocationid;
var i;
for (i=0;i < subonecount; i++)
{
if (subsubcat[i][1] == sublocationid)
{
document.catform.subsubid.options[document.catform.subsubid.length] = new Option(subsubcat[i][0], subsubcat[i][2]);
}
}

}
</script>
<form NAME="catform" ACTION="../Templates/receiveFormT.asp" METHOD="POST">
<%
rs.open sqlsupercat,MM_conn_String,1,1

if rs.eof and rs.bof then
response.write "errorNothing_"
response.end
else
%>
<select name="superid" onChange="changelocation(document.catform.superid.options[document.catform.superid.selectedIndex].value)" size="1">
<option selected value="">==大类==</option>
<% do while not rs.eof %>
<option value="<%=trim(rs("gcid"))%>">
<%=trim(rs("gcat"))%>
</option>
<% rs.movenext
loop
rs.close
end if %>
</select>
<select name="subid" size="1" onChange="subchangelocation(document.catform.subid.options[document.catform.subid.selectedIndex].value)">
<option selected value="">==子类==</option>
</select>
<select name="subsubid">
<option selected value="">==子类子类==</option>
</select> <br>
<input TYPE="submit" NAME="Subzmit" VALUE="Submit">
<input TYPE="RESET" NAME="Reset" VALUE="Reset">
</form>
<% set rs = nothing%>
</body>
</html>

shawl.qiu
2006-05-18

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场