日照市东港区创新电子技术中心
ndfweb.cn

网站设计常用代码片断


2009-06-04 15:07:33 (6355)


<optgroup LABEL="标题">
asc函数
Session.Contents.Remove("name")
response.Write("<script language=javascript>alert('密码或用户名输入错误!');history.go(-1)</script>")
url=Request.ServerVariables("HTTP_REFERER")
response.Write("<meta http-equiv=refresh content=0;URL="&url&">")
window.opener.location='" & url & "';
response.Redirect(Request.ServerVariables("HTTP_REFERER"))
response.Write("<meta http-equiv=refresh content=0;URL=javascript:history.back();>")
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
filepath=server.mappath("../upload/goods/" & img)
Fso.DeleteFile FilePath,true

style="overflow-x:visible"   自动换行
style="CURSOR:hand;"
style="background-color:transparent"
弹出模式窗口window.showModalDialog(url,window,"dialogWidth=500px;dialogHeight=360px;center=yes;middle=yes;help=no;status=no;scroll=no")
javascript:window.close();
onKeyUp="this.value=this.value.replace(/\D/,'')"
onclick="return confirm('确定要删除吗?');"
<div style="OVERFLOW-Y: auto; HEIGHT: 300px">
onload="javascript:if(this.width>500)this.width=500"
style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all"
onKeyUp="this.value=this.value.replace(/\D/,'')"
style="FILTER:alpha(opacity=99) shadow(color=#bbbbbb,direction=150);"//投影

Function ToMD5(ByVal InputString As String) As String
        Dim code, MD5
        Dim dataToHash As Byte() = (New System.Text.ASCIIEncoding).GetBytes(InputString)
        Dim hashvalue As Byte() = CType(System.Security.Cryptography.CryptoConfig.CreateFromName("MD5"), System.Security.Cryptography.HashAlgorithm).ComputeHash(dataToHash)
        Dim i As Integer
        For i = 0 To 15 '选择32位字符的加密结果
            MD5 += Hex(hashvalue(i)).ToLower
        Next
        Return MD5
    End Function
'================随机数============
Randomize()
psw=Int((999999-100000+1)*Rnd(now())+100000)
'==================================
连接数据库:
<!--#include file="conn.asp"-->
photo=Replace(Request.Form("photo"),"'","''")
<%
Server.scriptTimeout="10"
connstr="DBQ="+server.mappath("数据文件.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=Server.CreateObject("ADODB.connection")
conn.open connstr
%>

<%
sql="select * from bbs order by date desc"

rs.open sql,conn,3
if rs.recordcount>0 then
rs.pagesize=20
if request("page")<>"" then
  epage=cint(request("page"))
   if epage<1 then epage=1
   if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage

for i=1 to rs.pagesize
if rs.bof or rs.eof then exit for%>
<%rs.movenext
next
else

end if
rs.close%>
读取:
读取数量:set sl=conn.execute("select count(*) as counts from news where types="&rs("ids")&" ")
=sl("counts")
写入:
set savereg=conn.execute("insert into reg(user,psw,mail,sex)values('"&user&"','"&psw&"','"&mail&"','"&sex&"')")
修改:set savebbs=conn.execute("update bbs set click = "&cl&" where id="&id&"")


查询:sql="select * from bbs where body like '%"&key&"%' or title like '%"&key&"%' order by date desc"
搜索:

删除:set delbbs=conn.execute("delete*from danwei where id="&id&"")
select * from table where name like [a-z]%
***********************翻页**********************
    <%if rs.pagecount=1 then%>
                  <td><div align="center">共<span class="STYLE10"><%=rs.pagecount%></span>页&nbsp;当前第<span class="STYLE10"><%=epage%></span>页&nbsp;&nbsp;首页&nbsp;上页&nbsp;下页&nbsp;尾页</div></td>
      <%elseif rs.pagecount=epage then%>
       <td><div align="center">共<span class="STYLE10"><%=rs.pagecount%></span>页&nbsp;当前第<span class="STYLE10"><%=epage%></span>页&nbsp;<a href="news.asp">首页</a>&nbsp;<a href="news.asp?page=<%=epage-1%>">上页</a>&nbsp;下页&nbsp;尾页</div></td>
       <%elseif epage=1 then%>
       <td><div align="center">共<span class="STYLE10"><%=rs.pagecount%></span>页&nbsp;当前第<span class="STYLE10"><%=epage%></span>页&nbsp;首页&nbsp;上页&nbsp;<a href="news.asp?page=<%=epage+1%>">下页</a> <a href="news.asp?page=<%=rs.pagecount%>">尾页</a></div></td>
       <%elseif epage=rs.pagecount then%>
       <td><div align="center">共<span class="STYLE10"><%=rs.pagecount%></span>页&nbsp;当前第<span class="STYLE10"><%=epage%></span>页&nbsp;<a href="news.asp">首页</a>&nbsp;<a href="news.asp?page=<%=epage-1%>">上页</a>&nbsp;下页&nbsp;尾页</div></td>
       <%else%>
       <td><div align="center">共<span class="STYLE10"><%=rs.pagecount%></span>页 当前第<span class="STYLE10"><%=epage%></span>页&nbsp;&nbsp;<a href="news.asp">首页</a> <a href="news.asp?page=<%=epage-1%>">上页</a> <a href="news.asp?page=<%=epage+1%>">下页</a> <a href="news.asp?page=<%=rs.pagecount%>">尾页</a></div></td>
       <%
       end if
       rs.close%>
**************************************************************
新数据库操作:
if request("id")="" then

  sql = "select top 1 * from link"
  Set rs = Server.CreateObject("ADODB.RecordSet")
  rs.Open sql,conn,1,3
 
  rs.addnew
 
 else
 
  sql = "select * from link where id="&request("id")
  Set rs = Server.CreateObject("ADODB.RecordSet")
  rs.Open sql,conn,1,3
  
end if


  rs("linkname")=request("linkname")
  rs("url")=trim(request("url"))
  rs("logo")=trim(request("logo"))
  rs("js")=trim(request("js"))
  rs.update
 
  rs.close
  set rs=nothing
end if
*****************************************************************
半透明 style="filter: alpha(opacity=70);"
***********************************************************
Java鼠标位置:
event.clientX,   event.clientY,     event.offsetX,   event.offsetY,   event.screenX,   event.screenY,   event.x,   and   event.y 
***************************************************
<%sql="select * from users order by times desc"
rs.open sql,conn,3
if rs.recordcount>0 then
rs.pagesize=rs.recordcount
for i=1 to rs.pagesize
if rs.bof or rs.eof then exit for%>

<%rs.movenext
next
else

end if
rs.close%>

<%sql2="select * from users order by times desc"
rs2.open sql2,conn,3
if rs2.recordcount>0 then
rs2.pagesize=rs2.recordcount
for i2=1 to rs2.pagesize
if rs2.bof or rs2.eof then exit for%>

<%rs2.movenext
next
else

end if
rs2.close%>
***************************************************
时间比较
if datediff("d",s1("onehfrq"),now())=0 then
'输出:xxxxxxxxxxxxxxxxxx
end if

这里标准写法.

datediff函数,是返回两个时间差,如果两个时间相差0,表示是同一天.
参数"d" 表示天
"m" 表示月
"y" 表示年
"h"小时
"m"分钟
"s"秒
**************************************************
function NoHtml(str) '消除Html代码
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
str = replace(replace(str,"<BR>","{br}"),"<br>","{br}")
re.Pattern="(\<.[^\<]*\>)"
str=re.replace(str," ")
re.Pattern="(\<\/[^\<]*\>)"
str=re.replace(str," ")
str = replace(str,"{br}","<br>")
nohtml=str
set re=nothing
end function
*************************************************

了解更多请访问:http://www.ndfweb.cn/news-357.html
  NDF俱乐部
  国际域名注册
  建站咨询
合作伙伴:万网 | 新网 | 新网互联 NDF网站建设淘宝店 | 实用工具 | 外貿網站建設 | 联系我们
鲁公网安备 37110202000336号 Sitemap - RSSRSS订阅