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

ASP
ASP应用 用GetString来提高ASP的速度
ASP怎样可以获得代码中第一张图片地址
ASP开发经验谈 ASP开发10条经验总结
如何用ASP来获取客户端真实IP的地址?
用ASP实现就MP3曲目信息的操作全攻略
ASP中连接数据库的错误解决新解决办法
ASP后门之终极伪装
ASP生成静态htm页面基本代码
session在验证管理登陆时的使用方法
asp当中判断函数一览
IIS6.0 ASP 错误解析
ASP与JSP的区别和联系
几种打开记录集方式的比较
cookie和session机制之间的区别与联系
ASP的含义、功能和选择
ASP中巧用Response属性 -- contenttype
ASP内置对象Request和Response的详解
ASP错误大全
人文的ASP开发基础入门之简介
ASP 3.0高级编程(十二)

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


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