<%@ Language=VBScript %>
<%'定义用于从给定文件读取票数的函数:
Function ReadCount(CFile)
Dim objFSO,objTS
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTs = objFSO.OpenTextFile(Server.MapPath(CFile),1,True)
If Not objTS.AtEndOfStream Then
ReadCount = CLng(objTS.ReadLine)
Else
ReadCount = 0
End If
objTS.Close
Set objFSO=NothingEnd Function
'定义用于将累计票数写入指定文件的Sub过程:
Sub WriteCount(CFile,Count)
Dim objFSO,objTS
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(Server.MapPath(CFile),2,True)
objTS.WriteLine(Count)
objTS.Close
Set objFSO=Nothing End Sub%>
<%Dim Vote,London1,Paris1,Sanfran1'锁定Application变量:
Application.Lock'获取浏览者所投票的城市:Vote = Request("Vote")'从相应文件分别读取个城市已获得的票数:London1 = ReadCount("London.txt")Paris1 = ReadCount("Paris.txt")Sanfran1 = ReadCount("Sanfran.txt")'判断当前得票的城市,并为其票数加1后写入对应文件:If Vote="London" Then London1=London1+1 WriteCount "London.txt",London1ElseIf Vote="Paris" Then Paris1=Paris1+1 WriteCount "Paris.txt",Paris1ElseIf Vote="Sanfran" Then Sanfran1=Sanfran1+1 WriteCount "Sanfran.txt",Sanfran1End If'解除对Application变量的锁定:Application.UnLock%><html><head><meta http-equiv="Content-Language" content="zh-cn"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"><title>魅力城市网上投票</title></head><body bgcolor="#3366FF"><p align="center"><img border="0" src="poll.jpg" width="413" height="80"></p><div align="center"> <table border="0" width="440" height="138"> <tr> <td width="33%" height="96"><a href="poll.asp?Vote=London"> <img border="0" src="LONDON.GIF" width="101" height="87"> </a></td> <td width="33%" height="96"><a href="poll.asp?Vote=Paris"> <img border="0" src="PARIS.GIF" width="100" height="95"> </a></td> <td width="34%" height="96"><a href="poll.asp?Vote=Sanfran"> <img border="0" src="SANFRAN.GIF" width="101" height="88"> </a/></td> </tr> <tr> <td width="33%" height="33"><font color="#FFFFFF" size="4"> 伦敦得票数:<% = London1 %></font></td> <td width="33%" height="33"><font color="#FFFFFF" size="4"> 巴黎得票数:<% = Paris1 %></font></td> <td width="34%" height="33"><font color="#FFFFFF" size="4"> 旧金山得票数:<% = Sanfran1 %></font></td> </tr> </table></div><p align="center"><font face="楷体_GB2312" size="4"> 请用鼠标点击一下您所喜欢的城市图片,</font></p><p align="center"><font face="楷体_GB2312" size="4"> 该市就可获得您宝贵的一票!</font></p></body></html>
<%'定义用于从给定文件读取票数的函数:
Function ReadCount(CFile)
Dim objFSO,objTS
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTs = objFSO.OpenTextFile(Server.MapPath(CFile),1,True)
If Not objTS.AtEndOfStream Then
ReadCount = CLng(objTS.ReadLine)
Else
ReadCount = 0
End If
objTS.Close
Set objFSO=NothingEnd Function
'定义用于将累计票数写入指定文件的Sub过程:
Sub WriteCount(CFile,Count)
Dim objFSO,objTS
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(Server.MapPath(CFile),2,True)
objTS.WriteLine(Count)
objTS.Close
Set objFSO=Nothing End Sub%>
<%Dim Vote,London1,Paris1,Sanfran1'锁定Application变量:
Application.Lock'获取浏览者所投票的城市:Vote = Request("Vote")'从相应文件分别读取个城市已获得的票数:London1 = ReadCount("London.txt")Paris1 = ReadCount("Paris.txt")Sanfran1 = ReadCount("Sanfran.txt")'判断当前得票的城市,并为其票数加1后写入对应文件:If Vote="London" Then London1=London1+1 WriteCount "London.txt",London1ElseIf Vote="Paris" Then Paris1=Paris1+1 WriteCount "Paris.txt",Paris1ElseIf Vote="Sanfran" Then Sanfran1=Sanfran1+1 WriteCount "Sanfran.txt",Sanfran1End If'解除对Application变量的锁定:Application.UnLock%><html><head><meta http-equiv="Content-Language" content="zh-cn"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"><title>魅力城市网上投票</title></head><body bgcolor="#3366FF"><p align="center"><img border="0" src="poll.jpg" width="413" height="80"></p><div align="center"> <table border="0" width="440" height="138"> <tr> <td width="33%" height="96"><a href="poll.asp?Vote=London"> <img border="0" src="LONDON.GIF" width="101" height="87"> </a></td> <td width="33%" height="96"><a href="poll.asp?Vote=Paris"> <img border="0" src="PARIS.GIF" width="100" height="95"> </a></td> <td width="34%" height="96"><a href="poll.asp?Vote=Sanfran"> <img border="0" src="SANFRAN.GIF" width="101" height="88"> </a/></td> </tr> <tr> <td width="33%" height="33"><font color="#FFFFFF" size="4"> 伦敦得票数:<% = London1 %></font></td> <td width="33%" height="33"><font color="#FFFFFF" size="4"> 巴黎得票数:<% = Paris1 %></font></td> <td width="34%" height="33"><font color="#FFFFFF" size="4"> 旧金山得票数:<% = Sanfran1 %></font></td> </tr> </table></div><p align="center"><font face="楷体_GB2312" size="4"> 请用鼠标点击一下您所喜欢的城市图片,</font></p><p align="center"><font face="楷体_GB2312" size="4"> 该市就可获得您宝贵的一票!</font></p></body></html>