当前位置: 首页 > 图文教程 > 网络编程 > ASP > 让网站活起来(3)

ASP
用asp怎样编写文档搜索页面(5)
用asp怎样编写文档搜索页面(6)
ASP.NET: XML计数器第二版
ASP.NET: XML留言版第二版
不用图像组件的ASP图像计数器
用ASP实现文档资料管理
用ASP实现号码转换程序实例
如何用SAFileUp上传文件?
jmail4.1用pop3收信的例子
功能非常全面的日期处理函数
一个检查E文拼写错误的Code
简单的加密方法:XOR
ASP连接执行程序
编写“公平”的ASP图形计数器
跟我学做最强功能的网站统计
用asp.net写的论坛程序
用asp.net写的论坛程序--论坛主页
用asp.net写的论坛程序--浏览贴及回复
用asp.net写的论坛程序--上贴保存
利用CDONTS发送邮件的ASP函数

ASP 中的 让网站活起来(3)


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

       投 票 例 子
  
  
  功能:对软件和电脑工作室栏目进行投票,选择你喜欢的栏目。
  实现方法:把投票的结果存在Result.txt文件中,当前工作的网页是Voting.asp,提交的对象是Voted.asp,当单击查看按钮时,可以查看当前选票的结果。中间存在的Bug,就是当提交之后,继续刷新Voted.asp,这样选票结果会自动的添加,想想这是为什么?用什么方法来解决?你时候碰到过类似的网站。
  
  Voting.asp的关键是:
  1:显示查看结果
  <script language=javascript>
  function windowOpen(loadpos)
  { window.open(loadpos,"surveywin","toolbar,resizable,scrollbars,dependent,width=400,height=480");
  }
  </SCRIPT>
  
  2:提交数据给Voted.asp <form method="POST" action="Voted.asp">
  
  3:Voted.asp的关键是对下面两句话,第一行保存的是软件栏目选票的数量,第二行保存的是电脑工作室栏目的选票数量。下面一段程序,就是根据提交的数据自动的更新软件栏目的选票数量或者电脑工作室栏目的选票数量。
  <%
  Set FileS= Server.CreateObject("Scripting.FileSystemObject")
  If Request.Form("R1")="Soft" then
  Set FileR= FileS.OpenTextFile(Server.MapPath("Result.txt"), 1, True)
  Soft = FileR.Readline
  Studio = FileR.Readline
  FileR.Close
  
  Soft=Int(Soft)+1
  Set FileR= FileS.OpenTextFile(Server.MapPath("Result.txt"), 2, True)
  FileR.WriteLine Soft
  FileR.WriteLine Studio
  FileR.Close
  Else
  Set FileR= FileS.OpenTextFile(Server.MapPath("Result.txt"), 1, True)
  Soft = FileR.Readline
  Studio = FileR.Readline
  FileR.Close
  
  Studio=Int(Studio)+1
  Set FileR= FileS.OpenTextFile(Server.MapPath("Result.txt"), 2, True)
  FileR.WriteLine Soft
  FileR.WriteLine Studio
  FileR.Close
  End If
  %>
  
  4:下面一段程序时获取两个栏目的选票数量,同时计算出百分比,和得到选票的数量。
  <%
  Set FileS= Server.CreateObject("Scripting.FileSystemObject")
  Set FileR= FileS.OpenTextFile(Server.MapPath("result.txt"), 1, True)
  OSoft=FileR.Readline
  OStudio=FileR.Readline
  FileR.Close
  
  nCount = Int(OSoft)+Int(OStudio)
  Soft= (100 * Int(OSoft) ) / Int(nCount)
  Studio= (100 * Int(OStudio)) / Int(nCount)
  
  Soft = FormatNumber(Soft, 2)
  Studio = FormatNumber(Studio, 2)
  %>