⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subs.asp

📁 用asp实现的通用网站管理系统。
💻 ASP
字号:
<%
'程序作用:通用分页及删除程序
'程序创建时间:  22:51 2001-8-5
'最后修改时间:  9:51 2001-8-6
'调用格式:Call fenye()
'程序说明:使用前需定义类似以下的内容
if session("adminflag")="" then Response.Redirect "default.asp"
'const thisprog="setnews.asp"
'dim sqlfenye,txtitle
'txtitle=request("searchtxt")
'if txtitle<>"" then
'  sqlfenye="select * from main where name like '%"&trim(txtitle)&"%' order by id desc"
'else
'  sqlfenye="select * from main order by id desc"
'end if
'Sub deleteid(id)
'  conn.execute "delete from main where id="&cstr(id)
'End sub

const MaxPerPage=15
dim totalPut
dim CurrentPage
dim TotalPages
dim idlist
dim i,j,rsfenye
set rsfenye=server.createobject("adodb.recordset")

Sub fenye()

if not isempty(request("page")) then
  currentPage=cint(request("page"))
else
  currentPage=1
end if

dim idarr,id
if not isempty(request("isDel")) and Request("submit")="删除" then
  idlist=request("isDel")
  if instr(idlist,",")>0 then
	 idArr=split(idlist)
	 for i = 0 to ubound(idarr)
	   id=clng(idarr(i))
	   Call deleteid(id)
	 next
  else
	 Call deleteid(clng(idlist))
  end if
end if

if not isempty(request("isUse")) and Request("submit")="有效" then
  idlist=request.form("isUse")
  if instr(idlist,",")>0 then
	 idArr=split(idlist)
	 for i = 0 to ubound(idarr)
	   id=clng(idarr(i))
	   Call isUseid(id)
	 next
  else
	 Call isUseid(clng(idlist))
  end if
end if

if not isempty(request("notisUse")) and Request("submit")="无效" then
  idlist=request.form("notisUse")
  if instr(idlist,",")>0 then
	 idArr=split(idlist)
	 for i = 0 to ubound(idarr)
	   id=clng(idarr(i))
	   Call notisUseid(id)
	 next
  else
	 Call notisUseid(clng(idlist))
  end if
end if
%>
<SCRIPT language=JavaScript>
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
e.checked = true;
}}
function FanAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.checked == true){ e.checked = false; }
else { e.checked = true;}
}}
</SCRIPT>
<div align="center"><center>
<table border="0" width="95%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%"><p align="center">
<form  method="post" action="<%=thisprog%>?action=fenye">
查找:  <input class=smallInput type="text" name="searchtxt" size="13" value="<%=request("searchtxt")%>"><input type="submit" value="查 询">
</form>
<form name=easyForm method=Post action="<%=thisprog%>?action=fenye">
    <div align="center">
<%
rsfenye.open sqlfenye,conn,1,1
if rsfenye.eof and rsfenye.bof then
  Call PrintMsg(" 还 没 有 任 何 内 容 ")
else
  totalPut=rsfenye.recordcount
  if currentpage<1 then
  currentpage=1
  end if
  if (currentpage-1)*MaxPerPage>totalput then
    if (totalPut mod MaxPerPage)=0 then
      currentpage= totalPut \ MaxPerPage
    else
      currentpage= totalPut \ MaxPerPage + 1
    end if
  end if
  if currentPage=1 then
       showpage totalput,MaxPerPage,thisprog
       showContent
        easySelect
       showpage totalput,MaxPerPage,thisprog
  else
     if (currentPage-1)*MaxPerPage<totalPut then
       	rsfenye.move  (currentPage-1)*MaxPerPage
       	dim bookmark
       	bookmark=rsfenye.bookmark
      	showpage totalput,MaxPerPage,thisprog
       	showContent
        easySelect
      	showpage totalput,MaxPerPage,thisprog
   else
	currentPage=1
      	showpage totalput,MaxPerPage,thisprog
      	showContent
        easySelect
      	showpage totalput,MaxPerPage,thisprog
	end if
	end if
'rsfenye.close
end if
End Sub

Sub easySelect()
Response.Write "<center><INPUT onclick=CheckAll(easyForm) type=button value=全选 name=chkall><INPUT onclick=FanAll(easyForm) type=button value=反选 name=clear2>"
End Sub

Sub showContent
dim i
i=0
%>
      <div align="center"><center><table border="1" cellspacing="0" width="589" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellpadding="0">
        <tr>
          <td width="46" align="center" bgcolor="#D0D0D0" height="20"><strong>ID</strong></td>
          <td width="322" align="center" bgcolor="#D0D0D0"><strong>名称</strong></td>
<%if session("adminflag")<3 then%>
          <td width="49" align="center" bgcolor="#D0D0D0"><input type='submit' name="Submit" value='有效'></td>
          <td width="49" align="center" bgcolor="#D0D0D0"><input type='submit' name="Submit" value='无效'></td>
<%end if%>
          <td width="48" align="center" bgcolor="#D0D0D0"><input type='submit' name="Submit" value='删除'></td>
        </tr>
<%do while not rsfenye.eof%>
        <tr>
          <td height="23" width="46"><p align="center"><%=rsfenye("id")%></td>
          <td width="322"><p align="center"><a href="<%=thisprog%>?action=mod&id=<%=rsfenye("id")%>"><%=rsfenye("name")%></a></td>
<%if session("adminflag")<3 then%>
          <td width="49"><p align="center"><input type="checkbox" name="isUse" value="<%=rsfenye("id")%>" <%if rsfenye("isUse") then response.write "checked"%>></td>
          <td width="49"><p align="center"><input type="checkbox" name="notisUse" value="<%=rsfenye("id")%>" <%if not rsfenye("isUse") then response.write "checked"%>></td>
<%end if%>
          <td width="48"><p align="center"><input type='checkbox' name='isDel' value='<%=cstr(rsfenye("ID"))%>'></td>
        </tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rsfenye.movenext
loop
rsfenye.close
%>
      </table>
      </center></div>
    </div></td>
  </tr>
</table></form>
</center></div><%
End Sub 

function showpage(totalnumber,maxperpage,filename)
  dim n
  if totalnumber mod maxperpage=0 then
     n= totalnumber \ maxperpage
  else
     n= totalnumber \ maxperpage+1
  end if
  response.write "<p align='center'>&nbsp;"
  if CurrentPage<2 then
    response.write "<font color='#000080'>首页 上一页</font>&nbsp;"
  else
    response.write "<a href="&filename&"?action=fenye&page=1&searchtxt="&txtitle&">首页</a>&nbsp;"
    response.write "<a href="&filename&"?action=fenye&page="&CurrentPage-1&"&searchtxt="&txtitle&">上一页</a>&nbsp;"
  end if
  if n-currentpage<1 then
    response.write "<font color='#000080'>下一页 尾页</font>"
  else
    response.write "<a href="&filename&"?action=fenye&page="&(CurrentPage+1)&"&searchtxt="&txtitle&">"
    response.write "下一页</a> <a href="&filename&"?action=fenye&page="&n&"&searchtxt="&txtitle&">尾页</a>"
  end if
    response.write "<font color='#000080'>&nbsp;页次:</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>页</font> "
    response.write "<font color='#000080'>&nbsp;共<b>"&totalnumber&"</b>个 <b>"&maxperpage&"</b>个/页</font> "
end function

Sub fenlei()

dim rsel,count
set rsel=server.createobject("adodb.recordset")
%>
<script language = "JavaScript">
var onecount1;
onecount1=0;
rootcat = new Array();
        <%
        count = 0
        rsel.open "select distinct r,mtype,m from type order by m asc",conn,1,1
        do while not rsel.eof 
        %>
rootcat[<%=count%>] = new Array("<%= trim(rsel("r"))%>","<%= trim(rsel("mtype"))%>","<%= trim(rsel("m"))%>");
        <%
        count = count + 1
        rsel.movenext
        loop
        rsel.close
        %>
onecount1=<%=count%>;

var onecount2;
onecount2=0;
subcat = new Array();
        <%
        count = 0
        rsel.open "select distinct m,stype,s from type order by s asc",conn,1,1
        do while not rsel.eof 
        %>
subcat[<%=count%>] = new Array("<%= trim(rsel("m"))%>","<%= trim(rsel("stype"))%>","<%= trim(rsel("s"))%>");
        <%
        count = count + 1
        rsel.movenext
        loop
        rsel.close
        %>
onecount2=<%=count%>;


function changem(locationid)
    {
    document.txForm.m.length = 0; 

    var locationid=locationid;
    var i;
    for (i=0;i < onecount1; i++)
        {
            if (rootcat[i][0] == locationid)
            { 
                document.txForm.m.options[document.txForm.m.length] = new Option(rootcat[i][1], rootcat[i][2]);
            }        
        }
        
    }

function changes(locationid)
    {
    document.txForm.s.length = 0; 

    var locationid=locationid;
    var i;
    for (i=0;i < onecount2; i++)
        {
            if (subcat[i][0] == locationid)
            { 
                document.txForm.s.options[document.txForm.s.length] = new Option(subcat[i][1], subcat[i][2]);
            }        
        }
        
    }    
    
</script>
<%
dim selo
rsel.open "select distinct r,rtype from type order by r asc",conn,1,1
if rsel.eof and rsel.bof then
response.write "请先添加栏目。"
response.end
else
%>
<select name="r" onChange="changem(document.txForm.r.options[document.txForm.r.selectedIndex].value)">
<%
do while not rsel.eof
if rsel("r")=r then
   selo="selected"
else
   selo=""
end if
%>
<option <%=selo%> value="<%=trim(rsel("r"))%>"><%=trim(rsel("rtype"))%></option>
<%
rsel.movenext
loop
end if
rsel.close
%>
</select> 
<select name="m" onChange="changes(document.txForm.m.options[document.txForm.m.selectedIndex].value)">                  
<%if mtype<>"" then
  response.write "<option selected value="&m&">"&mtype&"</option>"
else
  response.write "<option selected value=>请选栏目</option>"
end if%>
</select>
<select name="s">                  
<%if stype<>"" then
  response.write "<option selected value="&s&">"&stype&"</option>"
else
  response.write "<option selected value=>请选栏目</option>"
end if%>
</select><font color=red>**</font>
<%
End Sub

Sub showkeywords()
%>
<script language="JavaScript">
<!--

function keywords(keywords) {
document.txForm.keywords.value=keywords;
}
 
// -->

</script>
<font color=red>关键字索引:</font>(按名称排序)<br>
<%
rSub.open "select distinct keywords from main order by keywords asc",conn,1,1
do while not rSub.eof
 if left(rSub("keywords"),1)<>"!" then Response.Write "<a href=javascript:keywords('"&replace(rSub("keywords")," ","&nbsp;")&"')>"&rSub("keywords")&"</a><font color=red>*</font>"
rSub.movenext
loop
rSub.close
End Sub
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -