📄 function.asp
字号:
<%
'***********************************************************************
'说明:递归算法遍历产品类别
'作者:firste
'调用说明:firste_classselect(数据库链接,数据表名,id,深度,默认选择id)
'***********************************************************************
function firste_classselect(f_conn,f_tname,f_id,f_depth,f_sid)
Dim rs_m
Dim rs_m_cmd
Dim rs_m_numRows
dim i
if f_id=0 then
response.Write("<select name=""f_cid"" id=""f_cid"">")
response.Write("<option value=""0"">--选择类别--</option>")
end if
Set rs_m_cmd = Server.CreateObject ("ADODB.Command")
rs_m_cmd.ActiveConnection = f_conn
rs_m_cmd.CommandText = "SELECT * FROM "&f_tname&" WHERE f_up = "&f_id&" ORDER BY f_p ASC,fid asc"
rs_m_cmd.Prepared = true
Set rs_m = rs_m_cmd.Execute
rs_m_numRows = 0
while not rs_m.eof
response.Write "<option value="""&(rs_m.Fields.Item("fid").Value)&""" "
if trim(cstr(f_sid))=cstr((rs_m.Fields.Item("fid").Value)) then
response.Write("selected=""selected""")
end if
response.Write ">"
if f_depth=0 then
response.Write(rs_m.Fields.Item("f_title").Value)
else
for i=0 to f_depth
response.Write(" ")
next
response.Write("|-"&(rs_m.Fields.Item("f_title").Value))
end if
response.Write "</option>"
'if f_depth <1 then
call firste_classselect(f_conn,f_tname,rs_m.Fields.Item("fid").Value,f_depth+1,f_sid)
rs_m.movenext()
wend
rs_m.Close()
Set rs_m = Nothing
if f_id=0 then
response.Write("</select>")
end if
end function
'***********************************************************************
'说明:递归算法遍历类别
'作者:firste
'调用说明:firste_classselect(数据库链接,数据表名,id,深度,默认选择id)
'***********************************************************************
function firste_classselect_sql(f_conn,f_tname,f_id,f_depth,f_sid)
Dim rs_m
Dim rs_m_cmd
Dim rs_m_numRows
dim i
if f_id=0 then
'response.Write("<select name=""f_cid"" id=""f_cid"">")
'response.Write("<option value=""0"">--选择类别--</option>")
end if
Set rs_m_cmd = Server.CreateObject ("ADODB.Command")
rs_m_cmd.ActiveConnection = f_conn
rs_m_cmd.CommandText = "SELECT * FROM "&f_tname&" WHERE f_up = "&f_id&" ORDER BY f_p ASC,fid asc"
rs_m_cmd.Prepared = true
Set rs_m = rs_m_cmd.Execute
rs_m_numRows = 0
while not rs_m.eof
response.Write "<option value="""&(rs_m.Fields.Item("fid").Value)&""" "
if cint(f_sid)=cint(rs_m.Fields.Item("fid").Value) then
response.Write("selected=""selected""")
end if
response.Write ">"
if f_depth=0 then
response.Write(rs_m.Fields.Item("f_title").Value)
else
for i=0 to f_depth
response.Write(" ")
next
response.Write("|-"&(rs_m.Fields.Item("f_title").Value))
end if
response.Write "</option>"
if f_depth <1 then call firste_classselect_sql(f_conn,f_tname,rs_m.Fields.Item("fid").Value,f_depth+1,f_sid)
rs_m.movenext()
wend
rs_m.Close()
Set rs_m = Nothing
if f_id=0 then
'response.Write("</select>")
end if
end function
'***********************************************************************
'说明:信息提示函数
'作者:firste
'输入:
'输出:
'***********************************************************************
function firste_error(f_t,f_u)
response.Redirect "error.asp?error="&server.URLEncode(f_t)&"&url="&f_u
response.End()
end function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -