当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用文件写入建立简单的网上调查

ASP
ASP连接SQL2005数据库连接代码
ASP程序与SQL存储过程结合使用详解
asp 小偷采集程序原理与常用函数方法
防盗链接ASP函数
asp将table生成excel文件(xls)
asp实现新评论自动发短信提示的代码
asp最简单的生成验证码代码
ASP 常见对象总结(熟悉一下利用以后的开发使用)
ASP UTF-8编码生成静态网页的函数
ASP+FSO生成的网页文件默认编码格式以及转换成UTF-8编码方法
asp Access数据备份,还原,压缩类代码
asp fso操作类
ASP 自动采集实现代码
asp 一些支付接口
ASP 递归调用 已知节点查找根节点的函数
用asp实现读取文件的最后一行的代码
用asp实现的获取文件夹中文件的个数的代码
ASP与Excel结合生成数据表和Chart图的代码
iis7 ASP+Access数据库连接错误
ASP 日期的加减运算实现代码

ASP 中的 用文件写入建立简单的网上调查


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 30 ::
收藏到网摘: n/a

 

相信有个人主页的网友,是不是很想知道访客是
怎么评价自己的作品,从而给自己一个改进方向,
下面的网上调查就是其中一例:)

你需要支持FSO的空间,只需两个文件,一是处理
的页面poll.asp,还有一个是数据文件poll.txt,当
然还有一个是显示提交表单的页面,下面分别给出
代码:

1。poll.asp:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>本站调查</title>
<link href="news1.css" rel="stylesheet" type="text/css">
</head>
<body>
<p>
  <%
dim polled,total
dim pollper(4)
dim pollname(7)
dim pollnum(4)
polled=cint(Request.Form("select"))
set  fs= Server.CreateObject("scripting.filesystemobject")
poll=server.MapPath("poll.txt")
set textar=fs.opentextfile(poll,1,0,0)
if not session(polled) then
 i=0
while not textar.atendofstream
 getdata=textar.readline
 pollname(i)=left(rtrim(getdata),7)
 pollnum(i)=right(RTrim(getdata),4)
 if i=polled then
    j=cdbl(pollnum(i))+1
 pollnum(i)=right(space(6)&trim(cstr(j)),7)
 end if
    i=i+1
wend
textar.close
set textar1=fs.createtextfile(poll,-1,0)
totle=0
for j=0 to (i-1)
  total=total+cdbl(pollnum(j))
  textar1.writeline pollname(j)&pollnum(j)
  next
  textar1.close
%>
  <span class="news1"> 你认为本站哪些地方需要改进?</span></p>
  <%
  for j=0 to (i-1)
pollper(j)=cdbl(pollnum(j))/total
     width=500*pollper(j)
 %>
<table width="750" border="0" align="left">
<tr>
<td align="left" bgcolor="#CCCCCC">
<%Response.Write(trim(pollname(j))&"(")
Response.Write(formatnumber(pollnum(j),0)&")")
Response.Write("<br>")
Response.Write("<img src="/upload/tech/20091103/20091103101509_f1b6f2857fb6d44dd73c7041e0aa0f19.gif" width=")
Response.Write(width&"' height=10>")
Response.Write(formatpercent(pollper(j)) &"<p>")
next
Response.Write("总计:")
Response.Write(formatnumber(total,0))
%>
</td>
</tr>
</table>
<%
session(polled)=true
else
Response.Write("你已经投过票了,谢谢你的投票!")
end if
%>
<p>&nbsp; </p>
</body>
</html>

2.poll.txt:

页面的美工    27
内容的覆盖面   35
内容的更新速度     43
网站的访问量   53

你要显示的页面(表单):

<table width="100%" height="215" border="0" bordercolor="#FFFFFF" background="%20">
<tr>
<td height="20" align="center" background="images/bg1.gif" class="1">你认为本站哪些地方需改进?</td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" class="1"> <input name="select" type="radio" value="0" checked>
页面的美工 </td>
</tr>
<tr>
<td height="20" background=" " bgcolor="#FFFFFF" class="1">
内容的覆盖面 </td>
</tr>
<tr>
<td height="20" bgcolor="#FFFFFF" class="1"> <input type="radio" name="select" value="2">
内容的更新速度 </td>
</tr>
<tr>
<td height="20" background=" " bgcolor="#FFFFFF" class="1">
<input type="radio" name="select" value="3">
网站的访问量 </td>
</tr>
<tr>
<td height="66" align="center" bgcolor="#FFFFFF"><span class="1">
<input type="submit" name="Submit2" value="提交">
</span><a href="poll.asp">查看</a></td>
</tr>
</table>

是不是很简单,赶快自己做一个吧:)