asp的大虾们,看看你们的功底如何?顺便帮个忙.

蝈蝈俊 2000-03-17 01:34:00
在8848网站中有一个功能:当用户在一个下拉式列表框中选择一个地方,如北京,另一个列表马上变为北京的几个区,显然,它是把这两组数据读到本地,通过本地的javascript实现的,问如果我有三个数据表:一个为全国各省的编码,名称;一个为全国各省的市的名称,编号,归入那个省的对应编号;一个为每个市的区的编号,名称,归入市的编号. 如果我想用三个下拉式列表框实现当用户选择一个省时,另一个下拉式列表框的内容变为这个省的市,如果选择一个市,第三个下拉式列表框变为这个市的区.要求在这几次改变下拉式列表框的内容时不用提交窗体.
各位大虾帮我看看如何实现.
(目前我准备用数组读到本地,但中间有个问题一直让我头疼,如何实现javascript的数组到vbscript数组的转换,毕竟这是一个三维数组).
...全文
276 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
王释之 2000-03-19
  • 打赏
  • 举报
回复
我有一个源程序代码,自己也没用过;
global.asa
select.asp

global.asa:
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

'You can add special event handlers in this file that will get run automatically when special Active Server Pages events
'occur. To create these handlers, just create a subroutine with a name from the list below that corresponds to the event
'you want to use. For example, to create an event handler for Session_OnStart, you would put the following code into this
'file (without the comments):
'Sub Session_OnStart
'**Put your code here **
'End Sub

'EventName Description
'Session_OnStart Runs the first time a user runs any page in your application
'Session_OnEnd Runs when a user's session times out or quits your application
'Application_OnStart Runs once when the first page of your application is run for the first time by any user
'Application_OnEnd Runs once when the web server shuts down

</SCRIPT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
'==Visual InterDev Generated - DataConnection startspan==
'--Project Data Connection
Session("DataConn_ConnectionString") = "DBQ="+server.mappath("cars.mdb")+";DefaultDir=;;Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"
Session("DataConn_ConnectionTimeout") = 15
Session("DataConn_CommandTimeout") = 30
Session("DataConn_RuntimeUserName") = "admin"
Session("DataConn_RuntimePassword") = ""
'==Visual InterDev Generated - DataConnection endspan==
End Sub
</SCRIPT>

select.asp:
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<!--
This example illustrates filling an HTML <SELECT>
drop-down list with values from a database table and displaying
a subset of records from another database table based on the
user's selection.

Displaying the Data
--------------------
Two recordsets were created with two DataCommand Design-time controls:
DataCommand1 and DataCommand2.

DataCommand1 is a list of automobile manufacturers that are used to
populate the <SELECT> list.
SELECT `Manufacturer Name` FROM Manufacturers

DataCommand2 pulls automobile information out of the Autos table for
the specific manufacturer that the user chooses in the <SELECT> list.
The name of the <SELECT> is Manufacturer. A local variable named
Manufacturer stores the Request.Form("Manufacturer") value that is used
in the SELECT statement:
SELECT Manufacturers.`Manufacturer Name`, Autos.Auto_ID, Autos.Auto_Name
FROM Autos, Manufacturers
WHERE Autos.Manufacturer_ID = Manufacturers.Manufacturer_ID
AND (Manufacturers.`Manufacturer Name` = '[Manufacturer]')

Submitting the Form
--------------------
The following event setting in the <SELECT> tag causes the form to be
submitted when the user chooses a new value in the Select list:
ONCHANGE="Form1.submit()"
Adding this event was easy. By right-clicking the page in the Visual InterDev
editor and choosing Script Wizard, you can apply actions to objects in
a design environment.

-->

<%Manufacturer = Request.Form("Manufacturer")%>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Visual InterDev <SELECT> Sample</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF">
<p><font size="6"><strong>Auto Listing Page</strong></font></p>
<p> </p>
<!--METADATA TYPE="DesignerControl" startspan
<OBJECT classid="CLSID:7FAEED80-9D58-11CF-8F68-00AA006D27C2" height=24 id=DataCommand1
style="LEFT: 0px; TOP: 0px" width=151>
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_ExtentX" VALUE="3995">
<PARAM NAME="_ExtentY" VALUE="635">
<PARAM NAME="_StockProps" VALUE="0">
<PARAM NAME="DataConnection" VALUE="DataConn">
<PARAM NAME="MaxRecords" VALUE="0">
<PARAM NAME="CommandTimeout" VALUE="30">
<PARAM NAME="CacheSize" VALUE="10">
<PARAM NAME="CommandText" VALUE="SELECT `Manufacturer Name` FROM Manufacturers">
<PARAM NAME="CommandType" VALUE="0">
<PARAM NAME="CursorType" VALUE="0">
<PARAM NAME="LockType" VALUE="1">
<PARAM NAME="Prepared" VALUE="0">
<PARAM NAME="ParamCount" VALUE="0">
<PARAM NAME="OpenSqlDelimiter" VALUE="[">
<PARAM NAME="CloseSqlDelimiter" VALUE="]"></OBJECT>
-->
<%
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.ConnectionTimeout = Session("DataConn_ConnectionTimeout")
DataConn.CommandTimeout = Session("DataConn_CommandTimeout")
DataConn.Open Session("DataConn_ConnectionString"), Session("DataConn_RuntimeUserName"), Session("DataConn_RuntimePassword")
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set DataCommand1 = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT `Manufacturer Name` FROM Manufacturers"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = DataConn
DataCommand1.Open cmdTemp, , 0, 1
%>

<!--METADATA TYPE="DesignerControl" endspan-->
<p>Select the manufacturer:</p>
<FORM METHOD="POST" Action="select.asp" NAME="Form1">
<SELECT LANGUAGE="JavaScript" ONCHANGE="Form1.submit()" SIZE=1 NAME="Manufacturer">

<!-- Fill the <SELECT> list with values from the Manufacturers table -->
<% Do While Not DATACommand1.EOF %>
<%If Manufacturer = DataCommand1("Manufacturer Name") then%>
<OPTION SELECTED>
<%= DataCommand1("Manufacturer Name")%>
</option>
<%Else%>
<OPTION>
<%= DataCommand1("Manufacturer Name")%>
</option>
<%End if%>
<% DataCommand1.MoveNext
Loop %>
</SELECT>
</FORM>
<%if Manufacturer = "" then Manufacturer = "General Motors" %>
<p><strong>Cars Offered by <%=Manufacturer%> :</strong></p>
<table border="1">
<tr>
<td align="center"><strong>Manufacturer </strong></td>
<td align="center"><strong>Auto ID </strong></td>
<td align="center"><strong>AutoName </strong></td>
</tr>
<!--METADATA TYPE="DesignerControl" startspan
<OBJECT classid="CLSID:7FAEED80-9D58-11CF-8F68-00AA006D27C2" height=24 id=DataCommand2
style="LEFT: 0px; TOP: 0px" width=151>
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_ExtentX" VALUE="3995">
<PARAM NAME="_ExtentY" VALUE="635">
<PARAM NAME="_StockProps" VALUE="0">
<PARAM NAME="DataConnection" VALUE="DataConn">
<PARAM NAME="MaxRecords" VALUE="0">
<PARAM NAME="CommandTimeout" VALUE="30">
<PARAM NAME="CacheSize" VALUE="10">
<PARAM NAME="CommandText" VALUE="SELECT Manufacturers.`Manufacturer Name`, Autos.Auto_ID, Autos.Auto_Name FROM Autos, Manufacturers WHERE Autos.Manufacturer_ID = Manufacturers.Manufacturer_ID AND (Manufacturers.`Manufacturer Name` = '[Manufacturer]')">
<PARAM NAME="CommandType" VALUE="0">
<PARAM NAME="CursorType" VALUE="0">
<PARAM NAME="LockType" VALUE="1">
<PARAM NAME="Prepared" VALUE="0">
<PARAM NAME="ParamCount" VALUE="0">
<PARAM NAME="OpenSqlDelimiter" VALUE="[">
<PARAM NAME="CloseSqlDelimiter" VALUE="]"></OBJECT>
-->
<%
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.ConnectionTimeout = Session("DataConn_ConnectionTimeout")
DataConn.CommandTimeout = Session("DataConn_CommandTimeout")
DataConn.Open Session("DataConn_ConnectionString"), Session("DataConn_RuntimeUserName"), Session("DataConn_RuntimePassword")
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set DataCommand2 = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT Manufacturers.`Manufacturer Name`, Autos.Auto_ID, Autos.Auto_Name FROM Autos, Manufacturers WHERE Autos.Manufacturer_ID = Manufacturers.Manufacturer_ID AND (Manufacturers.`Manufacturer Name` = '" & Manufacturer & "')"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = DataConn
DataCommand2.Open cmdTemp, , 0, 1
%>

<!--METADATA TYPE="DesignerControl" endspan-->

<% Do While Not DATACommand2.EOF %> <tr>
<td><%= DataCommand2("Manufacturer Name") %> </td>
<td><%= DataCommand2("Auto_ID") %> </td>
<td><%= DataCommand2("Auto_Name") %> </td>
</tr>
<%
DataCommand2.MoveNext
Loop
%>
</table>
</BODY>
</html>
蝈蝈俊 2000-03-19
  • 打赏
  • 举报
回复
Befresh 谢谢你的代码,不过您有没有cars.mdb数据库,如果有的话请给我寄个,我的e_mail是:ghj1976@netease.com
蝈蝈俊 2000-03-18
  • 打赏
  • 举报
回复
如果用控件,那里有控件下载?
solomon 2000-03-17
  • 打赏
  • 举报
回复
关注, 不过好像可以使用控件远程读取数据。
蝈蝈俊 2000-03-17
  • 打赏
  • 举报
回复
8848的好像不是从数据库读的数据,它通过预先写入程序实现的,可能8848的人是为了速度的问题吧.
929 2000-03-17
  • 打赏
  • 举报
回复
在8848的源文件分析不出吗?关注
zdg 2000-03-17
  • 打赏
  • 举报
回复
看看:
请教已显示页面读取数据库的问题
http://www.midatech.com/csdn/expert/TopicView.asp?id=3546
相信对你有帮助...

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧