Vote.asp
Upload User: ahxunteng
Upload Date: 2022-05-16
Package Size: 1606k
Code Size: 7k
Development Platform:

VBScript

  1. <!--#include file="../inc/conn.asp" -->
  2. <%
  3. dim Action,ID,VoteType,VoteOption,sqlVote,rsVote
  4. Action=trim(Request("Action"))
  5. ID=Trim(request("ID"))
  6. VoteType=Trim(request("VoteType"))
  7. VoteOption=trim(request("VoteOption"))
  8. If Action = "Vote" And Id<> "" And VoteOption<>"" And Session("Voted") = "" Then
  9. if VoteType="Single" then
  10. conn.execute "Update Vote set answer" & VoteOption  & "= answer" & VoteOption & "+1 where ID=" & ID
  11. else
  12. dim arrOptions
  13. if instr(VoteOption,",")>0 then
  14. arrOptions=split(VoteOption,",")
  15. dim i
  16. for i=0 to ubound(arrOptions)
  17. conn.execute "Update Vote set answer" & cint(trim(arrOptions(i)))  & "= answer" & cint(trim(arrOptions(i))) & "+1 where ID=" & Clng(ID)
  18. next
  19. else
  20. conn.execute "Update Vote set answer" & VoteOption  & "= answer" & VoteOption & "+1 where ID=" & Clng(ID)
  21. end if
  22. end if
  23. session("Voted")="True"
  24. End If
  25. if ID<>"" then
  26. sqlVote="Select * from Vote Where ID=" & Clng(ID)
  27. else
  28. sqlVote="select top 1 * from Vote order by ID desc"
  29. end if
  30. Set rsVote = Server.CreateObject("ADODB.Recordset")
  31. rsVote.open sqlVote,conn,1,1
  32. %>
  33. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  34. <HTML>
  35. <HEAD>
  36. <TITLE>调查结果</TITLE>
  37. <META http-equiv=Content-Type content="text/html; charset=gb2312">
  38. <style type="text/css">
  39. A:link    {  color: #333333;TEXT-DECORATION: none }
  40. A:visited {  color: #333333;TEXT-DECORATION: none }
  41. A:active  {  color: #003300;TEXT-DECORATION: none }
  42. A:hover   {  color: #003300;TEXT-DECORATION: underline overline }
  43. .navtrail {  COLOR: #eeeeee; FONT-SIZE: 12px; LINE-HEIGHT: 12px }
  44. A.navtrail:link {  COLOR: #eeeeee; CURSOR: w-resize }
  45. A.navtrail:visited {  COLOR: #eeeeee; CURSOR: w-resize }
  46. A.navtrail:active {  COLOR: #eeeeee; CURSOR: w-resize }
  47. A.navtrail:hover {  COLOR: #eeeeee; CURSOR: e-resize }
  48. INPUT{BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc}
  49. <!--
  50. td {  font-family: "宋体"; font-size: 9pt; color: #333333; text-decoration: none}
  51. -->
  52. </style>
  53. </HEAD>
  54. <BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  55. <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#007AB5">
  56. <tr> 
  57. <td valign="top">
  58. <%
  59. if Action="Vote" and session("voted")<>"" then
  60. response.write "<font color='#FF0000'size='4'>"
  61.     if Session("UserName")<>"" then response.write Session("UserName") & ","
  62. response.write "<br><br>&nbsp;&nbsp;非常感谢您的投票!</font><br>"
  63. end if
  64. %>
  65. <table width="600" border="0" align="center" cellpadding="2" cellspacing="0" class="border">
  66. <tr align="center" class="title"> 
  67. <td height="35" colspan="3"><strong><font color="#FFFFFF">调 查 结 果</font></strong></td>
  68. </tr>
  69. <tr class="tdbg">
  70. <td>
  71. <table width="600" border="0" align="center" cellpadding="0" cellspacing="2">
  72. <tr> 
  73. <td width="140" align="right"><div align="center"><strong><font color="#FFFFFF">调查内容:</font></strong></div></td>
  74. <td colspan="2"><font color="#FFFFFF"><%=rsVote("Title")%></font></td>
  75. </tr>
  76. <tr> 
  77. <td width="140" align="right"><div align="center"><strong><font color="#FFFFFF">总投票数:</font></strong></div></td>
  78. <td colspan="2"
  79. > <font color="#FFFFFF">
  80. <%
  81.   dim totalVote
  82.   totalVote=0
  83.   for i=1 to 8
  84.    if rsVote("Select" & i)="" then exit for
  85. totalVote=totalVote+rsVote("answer"& i)
  86.   next
  87.   response.Write(totalVote & "票")
  88.   if totalVote=0 then totalVote=1
  89. %>
  90. </font></td>
  91. </tr>
  92. <tr> 
  93. <td colspan="3" align="center">&nbsp;</td>
  94. </tr>
  95. <tr> 
  96. <td width="140" align="center"><font color="#FFFFFF"><strong>投票选项</strong></font></td>
  97. <td width="64" align="right"><div align="center"><font color="#FFFFFF"><strong>票数</strong></font></div></td>
  98. <td width="388" align="center"><font color="#FFFFFF"><strong>百分比</strong></font></td>
  99. </tr>
  100. <%
  101.   for i=1 to 8
  102.    if trim(rsVote("Select" & i) & "")="" then exit for
  103. %>
  104. <tr> 
  105. <td width="140" align="right"><div align="center"><font color="#66CCFF"><%=rsVote("Select"& i)%></font> </div></td>
  106. <td align="right"> 
  107. <div align="center"><%
  108. response.write rsVote("answer"& i)
  109. %>
  110. </div></td>
  111. <td> 
  112. <%
  113. dim perVote
  114. perVote=round(rsVote("answer"& i)/totalVote,4)
  115. response.write "<img src='../Images/topBar_bg.gif' width='" & round(360*perVote) & "'height='15' align='absmiddle'>"
  116. perVote=perVote*100
  117. if perVote<1 and perVote<>0 then
  118. response.write "&nbsp;0" & perVote & "%"
  119. else
  120. response.write "&nbsp;" & perVote & "%"
  121. end if
  122. %>
  123. </td>
  124. </tr>
  125. <% next %>
  126. </table>
  127. </td>
  128. </tr>
  129. </table>
  130. <%
  131. if session("voted")="" then 
  132. if Session("UserName")<>"" then
  133. response.write Session("UserName") & ","
  134. end if 
  135.     response.Write "<br><br>您还没有投票,请您在此投下您宝贵的一票!"
  136. response.write "<form name='VoteForm'method='post'action='vote.asp'>"
  137. response.write "&nbsp;&nbsp;&nbsp;&nbsp;" & rsVote("Title") & "<br>"
  138. if rsVote("VoteType")="Single" then
  139. for i=1 to 8
  140. if trim(rsVote("Select" & i) & "")="" then exit for
  141. response.Write "<input type='radio'name='VoteOption'value='" & i & "'>" & rsVote("Select" & i) & "<br>"
  142. next
  143. else
  144. for i=1 to 8
  145. if trim(rsVote("Select" & i) & "")="" then exit for
  146. response.Write "<input type='checkbox'name='VoteOption'value='" & i & "'>" & rsVote("Select" & i) & "<br>"
  147. next
  148. end if
  149. response.write "<br><input name='VoteType'type='hidden'value='" & rsVote("VoteType") & "'>"
  150. response.write "<input name='Action'type='hidden'value='Vote'>"
  151. response.write "<input name='ID'type='hidden'value='" & rsVote("ID") & "'>"
  152. response.write "&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:VoteForm.submit();'><img src='../images/voteSubmit.gif' width='52'height='18'border='0'></a>&nbsp;&nbsp;"
  153.         response.write "<a href='Vote.asp?ID=" & rsVote("ID") & "&Action=Show'target='_blank'><img src='../images/voteView.gif' width='52'height='18'border='0'></a>"
  154. response.write "</form>"
  155. end if
  156. dim sqlOtherVote,rsOtherVote
  157. sqlOtherVote="Select * from Vote Where ID<>" & ID & " order by ID desc"
  158. Set rsOtherVote = Server.CreateObject("ADODB.Recordset")
  159. rsOtherVote.open sqlOtherVote,conn,1,1
  160. rsOtherVote.close
  161. set rsOtherVote=nothing
  162. %>
  163. <p align="center">【<a href="javascript:window.close();"><font color="#FFFFFF">关闭窗口</font></a>】<br>
  164. <br></p>
  165. </td>
  166. </tr>
  167. </table>
  168. </BODY></HTML>
  169. <%
  170. rsVote.Close()
  171. Set rsVote = Nothing
  172. call CloseConn()
  173. %>