当前位置: 代码迷 >> ASP >> 问一下这个有关问题!
  详细解决方案

问一下这个有关问题!

热度:77   发布时间:2012-02-22 19:36:56.0
问一下这个问题!!!!!
我想从数据库里面读取数据到第一个select
然后根据select的选择值从数据库里面读取数据生成第二个select

这个怎么做?主要是怎么将select的option值传递给asp处理函数?

------解决方案--------------------
貌似联动 select?
------解决方案--------------------
ajax动态树
------解决方案--------------------
如果是asp.net的话,可以直接用控件实现,不过每次更新选择都要刷新页面,不是很爽.
用ajax来做比较好.......
第一个select出发某js事件,然后通过ajax与服务器通讯,返回结果,生成第二个select就行了
------解决方案--------------------
<%@ Language=VBScript %>
<%
set objConn=Server.CreateObject( "ADODB.Connection ")
set objRS1=Server.CreateObject( "ADODB.Recordset ")
set objRS2=Server.CreateObject( "ADODB.Recordset ")
set objRS3=Server.CreateObject( "ADODB.Recordset ")
connstr = "Driver={SQL Server};Server=wonders-18floor;Database=xk;Uid=sa;Pwd=sa; "
'connstr = "provider=microsoft.jet.oledb.4.0;data source=E:\db2.mdb; " 连接access库
'connstr = "Driver={SQL Server};Server=服务器名;Database=数据库名; Uid=用户名;Pwd=密码; " 连接sqlserver库
objConn.open connstr
objRS1.open "select * from area where right(code,4)= '0000 ' ",objConn
objRS2.open "select * from area where right(code,4) <> '0000 ' and right(code,3)= '000 ' ",objConn
objRS3.open "select * from area where right(code,4) <> '0000 ' and right(code,3) <> '000 ' ",objConn
%>
<html>
<head>
<title> </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
</head>
<script language= "vbscript ">
Sub sel1_onchange
for i = thisform.sel2.length - 1 to 1 step -1
thisform.sel2.remove(i)
next
for i = thisform.sel3.length - 1 to 1 step -1
thisform.sel3.remove(i)
next
if thisform.sel1.value <> " " then
<%while not objRS2.eof%>
if Left(thisform.sel1.value,2) = Left( " <%=trim(objRS2( "code "))%> ",2) then
thisform.sel2.length = thisform.sel2.length + 1
thisform.sel2.options(thisform.sel2.length-1).value = " <%=objRS2( "code ")%> "
thisform.sel2.options(thisform.sel2.length-1).text = " <%=objRS2( "name ")%> "
end if
<%objRS2.movenext%>
<%wend%>
<%objRS2.movefirst%>
End If
End Sub
Sub sel2_onchange
for i = thisform.sel3.length - 1 to 1 step -1
thisform.sel3.remove(i)
next
if thisform.sel2.value <> " " then
<%while not objRS3.eof%>
if Left(thisform.sel2.value,3) = Left( " <%=trim(objRS3( "code "))%> ",3) then
thisform.sel3.length = thisform.sel3.length + 1
thisform.sel3.options(thisform.sel3.length-1).value = " <%=objRS3( "code ")%> "
thisform.sel3.options(thisform.sel3.length-1).text = " <%=objRS3( "name ")%> "
end if
<%objRS3.movenext%>
<%wend%>
<%objRS3.movefirst%>
End if
End Sub
</script>
<body>
<form name= "thisForm " target= "testSubmit ">
<table width= "980 " border= "0 " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td align= "right "> 省 </td>
<td align= "left ">
  相关解决方案