|
作者: NetFog [q70213526] 版主 | 登录 |
这是老问题了,今天俺自己动手用vb脚本随便写了个.无聊ING 写得很乱.程序效率也不怎么样.实现功能就算了.本人懒,不想再改行了.有时候再写个三级联动的.. 写得不好.给个建议咯. 数据库结构. 表1:MarketArea (区域市场表) MarketAreaID MarketAreaName 表2:Depart (下属产品部门) ID DepartName MarketAreaID 程序如下: <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="../inc/conn.asp"--> <% dim sql,rs,MarketAreaID(),MarketAreaName(),TatalRecord sql = "select MarketAreaID,MarketAreaName from MarketArea" Set RS=Server.CreateObject("Adodb.Recordset") rs.open sql,conn,1,3 TatalRecord = rs.recordcount redim MarketAreaID(TatalRecord-1) redim MarketAreaName(TatalRecord-1) if not rs.eof then for i=0 to ubound(MarketAreaID) MarketAreaID(i) = rs("MarketAreaID") MarketAreaName(i) = rs("MarketAreaName") rs.movenext next else response.write "您没有添加任何区域市场" rs.close set rs=nothing call DataBaseClose() response.end end if rs.close set rs=nothing %> <html> <head> <title></title> <script language=vbScript> <!-- public x(<%=ubound(MarketAreaID)%>) <% dim Dsql,Drs,DepartStr,tempstr for i=0 to ubound(MarketAreaID) Dsql = "select ID,DepartName from Depart where MarketAreaID="&MarketAreaID(i) Set Drs=Server.CreateObject("Adodb.Recordset") Drs.open Dsql,conn,1,3 DepartStr = MarketAreaID(i)&":" if not Drs.eof then for j=1 to Drs.Recordcount DepartStr = DepartStr&Drs("ID")&"|"&Drs("DepartName")&"," Drs.movenext next if DepartStr <> "" then if Right(DepartStr,1) = "," and len(DepartStr)>1 then DepartStr=left(DepartStr,InStrRev(DepartStr,",")-1) end if end if Drs.close set Drs = nothing tempstr = "x( "&i&" )="""&DepartStr&""""&vbcrlf response.write tempstr next %> function test(a,b) dim Anum,Anum2,TempNum,xl TempNum = "" Anum = a.selectedIndex Anum2 = Trim(Anum)&":" for i=0 to ubound(x) if Instr(x(i),Anum2) = 1 then TempNum = x(i) exit for end if next If TempNum <> "" then TempNum = replace(TempNum,Anum2,"") end if xl = split(TempNum,",") b.options.length = ubound(xl)+1 for i = 0 to ubound(xl) b.options(i).text = Split(xl(i),"|")(1) b.options(i).value = Split(xl(i),"|")(0) next end function --> </script> </head> <body> <select name="a" onChange="vbscript:test a,b"> <option value="0">请选择区域市场</option> <% for i=0 to ubound(MarketAreaID) response.write "<option value="&MarketAreaID(i)&">"&MarketAreaName(i)&"</option>"&vbcrlf next %> </select> <select name="b"> </select> </body> </html> <% call DataBaseClose() %> [此贴被 NetFog(q70213526) 在 11月27日16时58分 编辑过] |
地主 发表时间: 05-11-27 16:56 |
回复: aserict [aserict] 论坛用户 | 登录 |
给个演示嘛。 |
B1层 发表时间: 05-12-02 18:19 |
回复: NetFog [q70213526] 版主 | 登录 |
呵呵..俺没空间.公司的空间不能随便用咯.. |
B2层 发表时间: 05-12-02 23:10 |
回复: NetFog [q70213526] 版主 | 登录 |
http://www.scenic.com.cn/test/select.asp 一个小玩意.有什么好演示的.就给个吧..年底再清了他. |
B3层 发表时间: 05-12-02 23:38 |
回复: and [and] 论坛用户 | 登录 |
速度很慢 |
B4层 发表时间: 06-01-04 21:06 |
回复: NetFog [q70213526] 版主 | 登录 |
我的这边速度还可以啊. [此贴被 NetFog(q70213526) 在 01月05日10时06分 编辑过] |
B5层 发表时间: 06-01-05 10:06 |
回复: poemail [poemail] 论坛用户 | 登录 |
二级菜单怎么是空的? |
B6层 发表时间: 06-01-05 14:11 |
回复: NetFog [q70213526] 版主 | 登录 |
联动的啊..做得很差..因为我对JS差不多是一点不懂. |
B7层 发表时间: 06-01-05 22:47 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号