<% ' varBase 下拉式功能表等級 ' varSele 所選擇下拉式功能表項的資料庫ID ' varElem 下一級的表單名稱varBase=Request.QueryString("base") varSele=Left(Request.QueryString("sele"),InStr(Request.QueryString("sele"),"-")-1) varElem=Request.QueryString("elem") varDistName="" varAutoID="" Set conDB=Server.CreateObject("ADODB.CONNECTION") conDB.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ="&Server.Mappath("db1.mdb") sqlCommand="select * from table1 where filed1="&varBase&" and filed2="&varSele Set rsRecord=conDB.Execute(sqlCommand) While Not rsRecord.eof varDistName=varDistName&chr(34)&rsRecord("filed3")&chr(34) varAutoID=varAutoID&chr(34)&rsRecord("id")&chr(34) rsRecord.movenext If Not rsRecord.Eof Then varDistName=varDistName&"," varAutoID=varAutoID&"," End If Wend Response.Write("var varDistName=new Array("&varDistName&")"&vbcrlf) Response.Write("var varAutoID=new Array("&varAutoID&")"&vbcrlf) Response.Write("var varElem=eval("&chr(34)&"document.Form1."&varElem&chr(34)&")"&vbcrlf) Response.Write("varElem.length=varDistName.length+1;"&vbcrlf) Response.Write("for(var i=0;i<varDistName.length;i++){"&vbcrlf) Response.Write(" varElem.options[i+1].text=varDistName;"&vbcrlf) Response.Write(" varElem.options[i+1].value=varAutoID+'-'+varDistName;"&vbcrlf) Response.Write("}"&vbcrlf) Response.Write("varElem.selectedIndex=0;"&vbcrlf) %> |