你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:技术专栏 / Linux开发
让网站活起来(3)
 
投 票 例 子
  
  
  功能:对软件和电脑工作室栏目进行投票,选择你喜欢的栏目。
  实现方法:把投票的结果存在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)
  %>
(编辑:aniston)
  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089