[摘要]<label id=lab1 onclick="window.scroll(0,70)">书写留言</label></td> </tr&...
<label id=lab1 onclick="window.scroll(0,70)">书写留言</label></td>
</tr>
</table>
<p><iframe name="include" width="749" height="314" src="include.asp" style="BORDER-RIGHT: #000000 1px double; PADDING-RIGHT: 4px; BORDER-TOP: #000000 1px double; PADDING-LEFT: 4px; PADDING-BOTTOM: 1px; BORDER-LEFT: #000000 1px double; PADDING-TOP: 1px; BORDER-BOTTOM: #000000 1px double">
浏览器不支持嵌入式框架,或被配置为不显示嵌入式框架。</iframe></p>
<table border="1" cellpadding="0" cellspacing="0" bgcolor="#9933ff" style="BORDER-COLLAPSE: collapse" bordercolor="#111111" width="750" id="AutoNumber4" height="1">
<form method="POST" action="certain.asp">
<tr>
<td width="21" height="1" align="left" style="VERTICAL-ALIGN: middle; LINE-HEIGHT: 150%; LETTER-SPACING: 3pt" rowspan="3">留言赠语</td>
<td width="96" height="25" align="middle">您的名字:</td>
<td width="171" height="25" align="middle">
<INPUT size="20" name="textname" class="input1">
</td>
<td width="88" height="25" align="middle">您在何方:</td>
<td width="194" height="25" align="middle">
<INPUT size="20" name="textadd" class="input1">
</td>
<td width="173" height="25" align="middle" colspan="2">
<INPUT size="20" name="textmail" value="yourmail@" class="input1">
</td>
</tr>
<tr>
<td width="552" height="1" colspan="4" rowspan="2"
align="center">
<TEXTAREA style="border-style:double; border-width:3; WIDTH: 523px; HEIGHT: 37px; background-color:#CCCCFF; overflow:hidden" cols="72" rows="1" name="textmsg" class="input1">
</TEXTAREA></td>
<td width="10" height="1" rowspan="2" align="center"><img border="0" src="http://www.okasp.com/techinfo/pic/1.jpg" width="40" height="56" id=idface>
</td>
<td width="159" height="1" align="center"> <SELECT name="list" class="input1" style="WIDTH: 61;height:61" onchange="document.images['idface'].src=options[selectedIndex].value;">
<option value=http://www.okasp.com/techinfo/pic/1.jpg selected>头像1
<script language=vbscript>
for i=2 to 15 '''''循环,用以设定下拉列表中的另外14个文件
document.write("<option value=pic/"&i&".jpg>头像"&i)
next
</script>
</option>
</SELECT>
<INPUT style="WIDTH: 65px; HEIGHT: 19px" type="button" value="头像列表" class="input2">
</td>
</tr>
<tr>
<td width="159" height="1" align="center"><INPUT style="WIDTH: 65px; HEIGHT: 19px" type="reset" size="25" value="清空" class="input2">
<INPUT style="WIDTH: 65px; HEIGHT: 19px" type="submit" value="提交" class="input2"></td>
</tr>
</form>
</table>
</center>
<% '''''在浏览器的状态栏中显示类似"当前共有8条留言,分2页显示,最近留言的人是陈树"
status = "当前共有"& num &"条留言,分"& (num-1)\5+1 &"页显示,最近留言的人是"& guestXml.documentelement.lastchild.firstchild.text
Response.Write("<script>")
Response.Write("window.status="&chr(34)& status &chr(34))
Response.Write("</script>")
%>
</body>
</html>
------------------------------------------------------------------------------
◆ 3 ◆ include.asp 该文件嵌入在主页面中,用来显示留言。
------------------------------------------------------------------------------
<% '使浏览器每次都从服务器载入内容
Response.Expires = -1
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "cache-control","no-store"
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>留言赠语</title>
<style>
<!--
p, br, body, td, select, input, form, textarea, option{ font-family: 宋体; font-size: 9pt }
table{border-style:double; border-width:3; padding:0; border-collapse: collapse}
.input1 { font-size: 9pt; border: 1px #000000 solid; background-color: #CCCCFF}
-->
</style>
</head>
<body bgcolor="#CC33FF">
<center>
<% '''''打开留言本数据文件
set guestXml = Server.CreateObject("MSXML.DOMDocument")
guestXml.load(Server.MapPath("guest.xml"))
set root = guestXml.documentelement
num = root.childNodes.length
page=Request.QueryString("page")
if page=Empty then '''''如果没有参数传递,即http://…/include.asp时的情况。
thispage = (num-1)\5+1 '''''每页显示5条留言,用thispage表示当前页码,无参数传递时显示最后一页。
if num mod 5 = 0 then
msgTotal = 5 '''''变量 msgTotal 表示当前页应该显示的留言数量
else
msgTotal = num mod 5
end if
else
thispage = page '''''类似于http://…/include.asp?page=1时的情况
if StrComp(thispage,(num-1)\5+1,1)=0 then
msgTotal = num mod 5
else
msgTotal = 5
end if
end if
msgNum = (thisPage-1)*5+msgTotal ''''msgNum表示当前页显示的留言是总条数的第N条
''''因为是倒序显示,所以第一条留言应该是(thisPage-1)*5+msgTotal
%>
<%for i=1 to msgTotal%>
<%
set xmlNode = root.childNodes.item(msgNum-1).childNodes ''定位到要读取的留言
name = xmlNode.item(0).text '''''name变量表示留言人的姓名.
pic = xmlNode.item(1).text '''''pic变量表示头像的地址。
add = xmlNode.item(2).text '''''add变量表示留言人的地址。
thistime = xmlNode.item(3).text '''''this变量表示留言时间。
''''不显示留言人的EMAIL。
msg = xmlNode.item(5).text ''''msg变量表示留言内容。
%>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#111111" width="100%" height="106" bgcolor="#FFFFFF">
<tr>
<td width="14%" rowspan="3" height="106" align="center">
<img border="0"
src=<%=pic%> width="100" height="143"></td>
<td width="9%" height="10" align="center" bgcolor="#99CCFF">姓名</td>
<td width="31%" height="10" align="center" bgcolor="#CCCCFF"><%=name%></td>
<td width="10%" height="10" align="center" bgcolor="#99CCFF">来自</td>
<td width="36%" height="10" align="center" bgcolor="#CCCCFF"><%=add%></td>
</tr>
<tr>
<td width="86%" height="83" colspan="4" align="center"
bgcolor="#9933FF"
style="line-height: 150%; margin-left: 50; margin-right: 50">
<TEXTAREA name="textmsg" class="input1" rows="6" cols="87" readonly><%=msg%></TEXTAREA></td>
</tr>
<tr>
<td width="86%" height="11" colspan="4" align=right bgcolor="#CCCCFF">第<%=thispage%>页
关键词:第3种途径---基于XML的ASP留言板