论坛风格切换
您好,欢迎光临本站!   登录 注册新用户
  • 2781阅读
  • 0回复

让网站活起来(3) [复制链接]

上一主题 下一主题
 

发帖
991
黑豆
637
威望
6815
贡献值
22
交易币
0
红豆
0
只看楼主 倒序阅读 0 发表于: 2008-12-19
— 本帖被 我爱小超 执行锁定操作(2013-01-24) —
功能:对软件和电脑工作室栏目进行投票,选择你喜欢的栏目。
  实现方法:把投票的结果存在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)
  %>