Homepageseo.com
Login
登录[Login]
Reg
注册[Reg]
Member
会员[Member]
BBs
论坛[BBs]
logout
退出[Logout]
Search
搜索[Search]
Search For:        Advanced Search   
Guide: 首页 >> IT技术专栏 >> 建站技术 >> 一个简单的投票程序

一个简单的投票程序

作者: 11830 来源: 互联网 日期: 2008-07-25,08:21

 

我自己开发的一个简单的投票程序

tp.asp文件

<%response.buffer=true%>
<html>
<head>
<title>投票处理页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#CCFFCC">
<%
ip=request("REMOTE_ADDR")
 name=request("name")
 if trim(name)="" then
  response.write "您没有选择要投票的人"
 else
  dim c(20)
  dim d(20)
  dim d2(20)
  Set fs=CreateObject("Scripting.FileSystemObject")
  Set a=fs.openTextFile(server.mappath("tp.txt"))
  tpcount=cint(a.readline)
  for i=0 to tpcount-1
   c(i)=a.readline
   d(i)=a.readline
  next
  for i=0 to tpcount-1
   if name=c(i) then
    d(i)=d(i)+1
   end if
  next
  Set fs = CreateObject("Scripting.FileSystemObject")
  Set a=fs.createTextfile(server.mappath("tp.txt"))
    a.writeline(tpcount)
    for i=0 to tpcount-1
      a.writeline(c(i))
      a.writeline(d(i))
    next
 end if
%>
<br><br><center><a href="http://www.chinaitpower.com/A/2001-11-11/tp.asp#" onclick="window.history.back()">返回</a></center>
</body>
</html>

 

tp.txt文件

--------

5
成龙
11
周润发
4
林青霞
1
林志颖
3
李连杰
3

 

tp1.asp文件

---------

<%
dim c(20)
dim d(20)
dim d2(20)
Set fs=CreateObject("Scripting.FileSystemObject")
Set a=fs.openTextFile(server.mappath("tp.txt"))
tpcount=cint(a.readline)
for i=0 to tpcount-1
c(i)=a.readline
d(i)=a.readline
next
all=0
for i=0 to tpcount-1
all=all+d(i)
next
for i=0 to tpcount-1
t=t+d(i)
next
if t>0 then
for i=0 to tpcount-1
d2(i)=formatpercent((d(i)/all),2,-1)
next
disptp=100
else
for i=0 to tpcount-1
d2(i)=formatpercent((0),2,-1)
next
disptp=0
end if

response.write "document.write("&chr(34)&"<table width=220 border=1 height=55 bordercolor=#0000FF cellspacing=0>"&chr(34)&");"
response.write "document.write("&chr(34)&"<tr><td width=80 height=26>参赛人</td>    <td width=80 height=26>票数</td><td width=60 height=26>投票率</td></tr>"&chr(34)&");"
for i=0 to tpcount-1
response.write "document.write("&chr(34)&"<tr><td width=80 height=24>"&c(i)&"</td><td width=80 height=24>"&d(i)&"</td><td width=60 height=24>"&d2(i)&"&nbsp;</td></tr>"&chr(34)&");"
next
response.write "document.write("&chr(34)&"<tr><td width=80 height=26>&nbsp;</td>    <td width=80 height=26>"&all&"</td><td width=60 height=26>"&disptp&"%&nbsp;</td></tr></table>"&chr(34)&");"
response.write "document.write("&chr(34)&"<form method=post action=../cgi/tp/tp.asp>我认为<select name=name>"&chr(34)&");"
for i=0 to tpcount-1
response.write "document.write("&chr(34)&"<option value="&c(i)&">"&c(i)&"</option>"&chr(34)&");"
next
response.write "document.write("&chr(34)&"</select>的故事写得比较好。<br><input type=submit name=send value=投票></form>"&chr(34)&");"
%>

责任编辑: admin 参与评论
免责申明: 本网转载内容均来自互联网,本网并不保证其内容的真实性。如果您认为本网站某部分的内容有侵权嫌疑,敬请立即通知我们,我们将在第一时间予以更改或删除。
Copyright © 2006 HomepageSeo.com ®. All rights reserved. Website development by 八桂网络科技 Author:Homepage 桂ICP备06012988号