XP_FUNC_RS.close Set XP_FUNC_RS = nothing %> <script language='javascript'> var t_sel="<%=sel1%>"; var s_sel="<%=sel2%>"; function putline(sel1,sel2){ var s1=sel1; var sn; s1.length=s_line.length+1; for(var i = 0;i < s_line.length;i++){ sn=s_line[i].split("|"); s1.options[i+1].value=sn[0]; s1.options[i+1].text=sn[1]; if(s1.options[i+1].value==t_sel){s1.options[i+1].selected=true; putstop(sel1,sel2);} } } function putstop(sel1,sel2){ var S1 = sel1; var S2 = sel2; var sn; sel1.selectedIndex; sel2.selectedIndex='0'; var y = 0; key = S1.options[S1.options.selectedIndex].value; if(key==""){S2.length=1; return false;} for(var i = 0;i < s_shop.length;i++){ sn = s_shop[i].split("|"); if(key==sn[1]){ y++; S2.length=y+1; S2.options[y].value=sn[0]; S2.options[y].text=sn[2]; if(s_sel!=""){ if (S2.options[y].value==s_sel){S2.options[y].selected=true;} }
用DATASET的GETCHILD()是不是也会刷新页面?
多级的联动菜单也可以这样
function output_select(S_NAME,S_SELECT_VALUE,S_LIST_VALUE,S_FIRST_NAME,S_ACTION,S_CHANGE_NAME,S_ACTION_NAME,S_QUAL)'S_NAME 下拉框名字
'S_SELECT_VALUE 下拉框自动选定的值
'S_LIST_VALUE 下拉框列表是否显示每个选项的值(1,为显示,0为不显示)
'S_FIRST_NAME 下拉框第一个默认选项,且值为空(s_first_name为空则不显示)
'S_ACTION 下拉框选定后是否执行刷新本页功能(1,为执行,0为不执行)
'S_CHANGE_NAME 下拉框选定后改变另一个文本框或下拉框的值为空,s_change_name为空则不改变
'S_ACTION_NAME 下拉框选定后执行刷新本页的程序名字
'S_QUAL 查询条件
'onchange javascript'
IF S_ACTION = 1 Then
Response.Write "<script language = 'JavaScript'>"+ chr(13) + chr(10)
Response.Write "function GoTo"& S_NAME &"(s){"+ chr(13) + chr(10)
if S_CHANGE_NAME<>"" then
dim S_CHANGE_NAME_arr
S_CHANGE_NAME_arr=Split(S_CHANGE_NAME, "$")
for i=0 to UBound(S_CHANGE_NAME_arr)
Response.Write "s."& S_CHANGE_NAME_arr(i) &".value='';" + chr(13) + chr(10)
next
end if
Response.Write "s.action='" & S_ACTION_NAME & "';"+ chr(13) + chr(10)
Response.Write "s.submit();"+ chr(13) + chr(10)
''' Response.Write "s.submit();"+ chr(13) + chr(10)
Response.Write "}</script>"+ chr(13) + chr(10)
END IF
Response.Write "<SELECT name='" & S_NAME & "' "
IF S_ACTION = 1 Then Response.Write " onChange=GoTo"& S_NAME &"(this.form) "
Response.Write ">"
IF S_FIRST_NAME<>"" Then Response.Write "<OPTION value=''>" & S_FIRST_NAME & "</OPTION>"Set XP_FUNC_RS = Server.CreateObject("ADODB.Recordset")
XP_FUNC_RS.OPEN S_QUAL,CONN,1,1do while not XP_FUNC_RS.eof
Response.Write "<option value='"
Response.Write XP_FUNC_RS(0) & "'"
if LCase(cstr(trim(S_SELECT_VALUE)))=LCase(cstr(trim(XP_FUNC_RS(0)))) then Response.Write " selected " Response.Write ">"
Response.Write XP_FUNC_RS(1)
if S_LIST_VALUE=1 then Response.write "/" & XP_FUNC_RS(0)
Response.Write "</OPTION>" XP_FUNC_RS.movenext
loop
XP_FUNC_RS.close
set XP_FUNC_RS=nothing
Response.Write "</SELECT>"
End Function
Sub putselect(S_QUAL,sel1,sel2)
dim s_line,s_no,s_shop,s_line_1
Set XP_FUNC_RS = Server.CreateObject("ADODB.Recordset")
XP_FUNC_RS.open S_QUAL,conn,1,1 '''rs(0) 店代码 rs(1) 店名 rs(2) 城市代码 rs(3)城市名
do while not XP_FUNC_RS.eof
if s_line_1<>XP_FUNC_RS(2) Then
if s_line="" then
s_line="'" & XP_FUNC_RS(2) & "|" & XP_FUNC_RS(3) & "'"
else
s_line=s_line&",'" & XP_FUNC_RS(2) & "|" & XP_FUNC_RS(3) & "'"
end if
s_line_1=XP_FUNC_RS(2)
end if
if s_shop="" then
s_shop="'" & XP_FUNC_RS(0) & "|" & XP_FUNC_RS(2) & "|" & XP_FUNC_RS(1) & "'"
else
s_shop=s_shop & ",'" & XP_FUNC_RS(0) & "|" & XP_FUNC_RS(2) & "|" & XP_FUNC_RS(1) & "'"
end if
XP_FUNC_RS.movenext
loop
Response.Write "<script language='javascript'>" + chr(13) + chr(10)
Response.Write "var s_line=new Array("&s_line&")" + ";"+ chr(13) + chr(10)
Response.Write "var s_shop=new Array("&s_shop&")" + ";"+ chr(13) + chr(10)
Response.Write "</script>" + chr(13) + chr(10)
XP_FUNC_RS.close
Set XP_FUNC_RS = nothing
%>
<script language='javascript'>
var t_sel="<%=sel1%>";
var s_sel="<%=sel2%>";
function putline(sel1,sel2){
var s1=sel1;
var sn;
s1.length=s_line.length+1;
for(var i = 0;i < s_line.length;i++){
sn=s_line[i].split("|");
s1.options[i+1].value=sn[0];
s1.options[i+1].text=sn[1];
if(s1.options[i+1].value==t_sel){s1.options[i+1].selected=true;
putstop(sel1,sel2);}
}
}
function putstop(sel1,sel2){
var S1 = sel1;
var S2 = sel2;
var sn;
sel1.selectedIndex;
sel2.selectedIndex='0';
var y = 0;
key = S1.options[S1.options.selectedIndex].value;
if(key==""){S2.length=1; return false;}
for(var i = 0;i < s_shop.length;i++){
sn = s_shop[i].split("|");
if(key==sn[1]){
y++;
S2.length=y+1;
S2.options[y].value=sn[0];
S2.options[y].text=sn[2];
if(s_sel!=""){
if (S2.options[y].value==s_sel){S2.options[y].selected=true;}
}
}
}
}
</script>
<%end sub
%>