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

ASP
ASP 中 Split 函数的实例
存贮过程
asp内置对象 ObjectContext详解
如何写出优秀的ASP应用
用ASP制作强大的搜索引擎
ASP 系列函数大全
彩色校验码的制作
ASP中使用SQL语句教程
ASP提速技巧五则
ASP进度条
在电子商务中实现购物车的方法
ASP读取系统时区的错误行为修正
Rs.open sql,conn,A,B 的A、B各代表什么?
FSO组件操作实例技巧
用asp连接各种数据库的方法
WEB打印设置解决方案一
WEB打印设置解决方案二
WEB打印设置解决方案三
实例分析CSS属性Display与Visibility不同
每页都有的表头和打印分页

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 30 ::
收藏到网摘: 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)
  %>