28,390
社区成员
发帖
与我相关
我的任务
分享
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>自制留言板</title>
<script type="text/JavaScript">
<!--
//-->
</script>
<style type="text/css">
<!--
input
{
border:thin
}
body,input{background-color:#FFFFFF;}
textarea
{
background:#FFFFFF;
}
.display { visibility:visibile ;z-index:3;
width:500px;
height:300px;
position:absolute;
z-index:1;
border-width:thick;
text-align:center;}
body{
text-align:center;
}
.undisplay { visibility:hidden ;z-index:1;width:500px;
height:300px;
position:absolute;
z-index:1;
border-width:thick;
text-align:center;}
span
{
color:#FF0066
}
textarea
{
z-index:2;
}
table td span
{
height:60px;
width;60px;
text-align:left;
}
-->
</style>
</head>
<body>
<table><tr><td><table height= "500" width="1000" border="1" cellspacing="0" cellpadding="0">
<caption style=" font-size:24px;"align="top">
留言板
</caption>
<%
dim cnn,cnnstr,sqlsave,sqlread,rs,nickname,comments,page,temp,num
nickname=Request("nickname")
comments=Request("comments")
page=request.querystring("page")
set cnn=Server.CreateObject("ADODB.Connection")
set rs=Server.CreateObject("ADODB.Recordset")
cnnstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("mdb\comments.mdb")
sqlsave="INSERT INTO MAIN VALUES ("&"'"&nickname &"'"&","&"'"&comments&"')"
sqlread="SELECT * FROM MAIN"
cnn.open cnnstr
if nickname<>"" and comments<>"" then
'response.write("<script>alert("""&nickname&""");</script>")
rs.open sqlsave,cnn,1,3
End if
rs.open sqlread,cnn,3,2
if page<1 or page=null or page="" then
page=1
else
page=clng(page)
end if
if not (rs.eof and rs.bof) then
rs.absolutepage=page
rs.pagesize=2
num=1
do while not(rs.eof or num>rs.pagesize)
temp=replace(rs("comments"),vbcrlf,"<br>")
temp = Replace(temp,"em<","<img src=""pic\兔斯基QQ表情")
temp = replace(temp,"em>",".gif""></img>")
response.write "<tr align=""left""><td width=""150"">"&"游客:"&rs("nickname")&"</td><td align=""left"">"&temp&"</td></tr>"
num=num+1
rs.MoveNext
loop
end if
%>
</table></td></tr>
<tr>
<td coslpan="2">
<%
response.write("<script>alert("""&rs.recordcount&""");</script>")
if page<>1 and page <> rs.pagecount then
response.write("<a href=""index.asp?page=1"">第一页</a> ")
response.write("<a href=""index.asp?page="&page-1&""">"&"上一页"&"</a> ")
response.write(page&" ")
response.write("<a href=""index.asp?page="&page+1&""">"&"下一页"&"</a> ")
response.write("<a href=""index.asp?page="&rs.pagecount&""">"&"最后一页"&"</a> ")
elseif page=1 then
response.write("<a href=""index.asp?page="&page+1&""">"&"下一页"&"</a> ")
response.write("<a href=""index.asp?page="&rs.pagecount&""">"&"最后一页"&"</a> ")
elseif page=rs.pagecount then
response.write("<a href=""index.asp?page=1"">1</a> ")
response.write("<a href=""index.asp?page="&page-1&""">"&"上一页"&"</a> ")
response.write(page&" ")
end if
rs.close
set rs=nothing
set cnn=nothing
%></td>
</tr>
<tr>
<td>
<div align="left" >
<form action="index.asp" method="post" onsubmit="return check();">昵称:
<input name="nickname" type="text" size="7" height="23" />
<span ><a onclick="document.getElementById('expression').className='display';" href="#">插入表情</a></span>
<table id="expression" class="undisplay" >
<tr>
<th align="center" cellspacing="10" colspan="6">
<a style="color:#FF0000;" id="closebutton"href="#">关闭</a> </th >
</tr>
<%
dim i,j,cols,rows
cols=5
rows=5
for i=0 to rows
response.Write("<tr>")
for j=0 to cols
response.write("<td bordercolor=""red"" ><a href=#><img value="&"em<"&(j+i*(rows+1))+1&"em>"&" src=pic\兔斯基QQ表情"&(j+i*(rows+1))+1&".gif></img></a></td>")
next
response.write("</tr>")
next
%>
</table>
<textarea style=" display:block;"rows = "20" cols = "88" name="comments" wrap="physical"></textarea>
<input name="submit" value="submit" type="submit" />
<input name="reset" value="reset" type="reset" />
</form>
</div>
</td></tr></table>
</body>
<script type="text/javascript">
var i = document.getElementsByTagName("img").length;
var temp=document.getElementsByTagName("img");
for(var j = 0 ; j< i;j++)
{
temp[j].onclick=function()
{
document.getElementsByTagName("textarea")[0].value+=this.value;
}
}
document.getElementById("closebutton").onclick=function (){
document.getElementById("expression").className="undisplay";
}
function check()
{
var tt = document.getElementsByTagName("input")[0];
var comments = document.getElementsByTagName("textarea")[0];
if(tt.value && comments.value)
{ alert("留言已经成功提交!");
return true;
}
alert("不能留空!");
return false;
}
</script>
</html>
<%
Function makeWordsArray(strWords)
Dim wordsarray
If InStr(strRecords,",")>0 then
wordsarray=Split(strRecords,",")
ElseIf InStr(strRecords," ")>0 then
wordsarray=Split(strRecords," ")
Else
wordsarray=array(strRecords)
End If
makeWordsArray=wordsarray
End Function
Dim strCatagory,strRecords,strBrand
Dim strSymbol:strSymbol=5 '大于ratemodel数组的上限即可
Dim strSQL,strKeyarray
Dim strMessage,strSitePrix
strCatagory=Trim(Request("catagory"))
strRecords=Trim(Request("record"))
strBrand=LCase(Trim(Request("brand")))
If Not IsEmpty(Request("catagory")) Or strCatagory<>"" then
If seekArray(ratemodel,strCatagory) then
strSymbol=getArrayIndex(ratemodel,strCatagory)
End If
Else
strBrand=false
End If
If strRecords<>"" then
strKeyarray=makeWordsArray(strRecords)
'Response.write "------------------------------------------->"&UBound(strKeyarray)
else
strKeyarray=""
'Response.write "------------------------------------------->"&strKeyarray
end if%>
<html>
....
<%
Dim jumpPage:jumpPage="relates.asp?brand="&strBrand&"&catagory="&strCatagory&"&record="&strRecords
'...
%>
<div id="pagepanel"> <%call showpage(jumpPage,strRs.RecordCount,strRs.PageSize,CurrentPage,5,"current",true)%> </div>
<%
'***********************************************
'函数名:PasteURL
'作 用:向地址中加入 ? 或 &
'参 数:strUrl ----网址
'返回值:加了 ? 或 & 的网址
'***********************************************
function PasteURL(strUrl)
if strUrl="" then
PasteURL=""
exit function
end if
'如果传入的URL末尾不是"?",有两种情况:
'1.无“?”,此时需加入一个“?”
'2. 有“?”再判断有无“&”
if InStr(strUrl,"?")<len(strUrl) then
if InStr(strUrl,"?")>1 then
if InStr(strUrl,"&")<len(strUrl) then
PasteURL=strUrl & "&"
else
PasteURL=strUrl
end if
else
PasteURL=strUrl & "?"
end if
else
PasteURL=strUrl
end if
end function
'***********************************************
'过程名:ShowPage
'作 用:显示“上一页 下一页”等信息
'参 数:sDesURL ----链接地址,可以是一个文件名,也可以是一个有一些参数所URL
' nTotalNumber ----总数量
' nMaxPerPage ----每页数量
' nCurrentPage ----当前页
' nBlock ----数字页码可示段的数量
' cPageStyle ----当前页码的CSS样式
' bSymbol ----是否显示标记位
'***********************************************
sub ShowPage(sDesURL, nTotalNumber, nMaxPerPage, nCurrentPage,nBlock,cPageStyle,bSymbol)
dim n, i,strTemp,strUrl,strStyle,poutStr
'计算页数
if nTotalNumber mod nMaxPerPage=0 then
n= nTotalNumber \ nMaxPerPage
else
n= nTotalNumber \ nMaxPerPage+1
end if
'判断nCurrentPage
if nCurrentPage < 1 then
nCurrentPage = 1
elseif nCurrentPage > n then
nCurrentPage = n
end if
strStyle=cPageStyle
If strStyle="" then strStyle="current"
'根据输入的sDesURL向它加入?或&
strUrl=PasteURL(sDesURL)
poutStr="<dl>"
if nCurrentPage<2 then
poutStr=poutStr&"<dt>INDEX</dt> <dt>PREV</dt>"
else
poutStr=poutStr& "<dt><a href='" & strUrl & "page=1'>INDEX</a></dt>"
poutStr=poutStr& "<dt><a href='" & strUrl & "page=" & (nCurrentPage-1) & "'>PREV</a></dt>"
end if
'mm页码标量
'limax数字页码的可示上限
'lilow数字页码的可示下限
'lisymbol上一个可示段的上限
'outStr数字页码的缓存字符串
Dim mm,limax,lilow,lisymbol,outStr
If n>1 then
outStr= "<dd><ul>"
'数字页码的可示上限
if nCurrentPage Mod nBlock >0 then
limax=((nCurrentPage \ nBlock) * nBlock) + nBlock
else
limax=(nCurrentPage \ nBlock) * nBlock
end if
'数字页码的可示下限
lilow=limax - nBlock+1
if limax>n then limax=n
'显示上一个标记位
if bSymbol then
if lilow mod nBlock>0 And lilow>1 then
lisymbol=lilow - 1 - nBlock
if lisymbol=0 then lisymbol=1
outStr=outStr& "<li><a href='" & strUrl & "page="&lisymbol&"'>"&lisymbol&"</a></li><li> ... </li>"
end if
end if
'打印数字页码
for mm=lilow to limax
outStr=outStr& "<li>"
if mm=nCurrentPage then
outStr=outStr& "<span class='"&strStyle&"'>"&mm&"</span>"
else
outStr=outStr& "<a href='" & strUrl & "page="&mm&"'>"&mm&"</a>"
end if
outStr=outStr& "</li>"
next
'显示最后一个标记位
if bSymbol then
if limax<n then
outStr=outStr& "<li> ... </li><li><a href='" & strUrl & "page="&n&"'>"&n&"</a></li>"
end if
end if
outStr=outStr& "</ul></dd>"
poutStr=poutStr&""&outStr
End If
if n-nCurrentPage<1 then
poutStr=poutStr& "<dt>NEXT</dt><dt>END</dt>"
else
poutStr=poutStr& "<dt><a href='" & strUrl & "page=" & (nCurrentPage+1) & "'>NEXT</a></dt>"
poutStr=poutStr& "<dt><a href='" & strUrl & "page=" & n & "'>END</a></dt>"
end if
poutStr=poutStr&"</dl><label>showing "&((nCurrentPage-1)*nMaxPerPage)+1&" - "
if nCurrentPage*nMaxPerPage> nTotalNumber then
poutStr=poutStr&""&nTotalNumber
else
poutStr=poutStr&""&nCurrentPage*nMaxPerPage
end if
poutStr=poutStr&" of "&nTotalNumber&"</label>"
Response.Write poutStr
end sub
%>