⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vote.asp

📁 使用Asp+Access+FSO+Jmail+Servu开发
💻 ASP
字号:
<!--#include file="inc/conn.asp" -->
<%
dim action,id,votetype,voteoption,sqlvote,rsvote
action=trim(request("action"))
id=trim(request("id"))
votetype=trim(request("votetype"))
voteoption=trim(request("voteoption"))
if action="vote" and voteoption="" and session("voted")="" then
response.write "<script>alert('对不起,投票不能为空!');location.href='javascript:window.close()'"
response.write "</script>"
response.end
end if
if action="vote" and voteoption<>"" and session("voted")<>"" then
response.write "<script>alert('对不起,请不要重复投票!');location.href='javascript:window.close()'"
response.write "</script>"
response.end
end if
if action = "vote" and id<> "" and voteoption<>"" and session("voted") = "" then
	if votetype="single" then
		conn.execute "update vote set answer" & voteoption  & "= answer" & voteoption & "+1 where id=" & id
	else
		dim arroptions
		if instr(voteoption,",")>0 then
			arroptions=split(voteoption,",")
			dim i
			for i=0 to ubound(arroptions)
				conn.execute "update vote set answer" & cint(trim(arroptions(i)))  & "= answer" & cint(trim(arroptions(i))) & "+1 where id=" & clng(id)
			next
		else
			conn.execute "update vote set answer" & voteoption  & "= answer" & voteoption & "+1 where id=" & clng(id)
		end if
	end if
	session("voted")="true"
	response.write "<script>alert('非常感谢您的投票!')"
	response.write "</script>"
end if
if id<>"" then
	sqlvote="select * from vote where id=" & clng(id)
else
	sqlvote="select top 1 * from vote order by id desc"
end if
set rsvote = server.createobject("adodb.recordset")
rsvote.open sqlvote,conn,1,1
%>
<html>
<head>
<title>调查结果</title>
<meta http-equiv=content-type content="text/html; charset=gb2312">
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body background="images/votebg.gif" leftmargin="0" topmargin="5" marginwidth="0" marginheight="0">
<table width="490" height="230" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#cccccc">
  <tr>   
    <td width="498" align="center" valign="top" bgcolor="#ffffff"> 
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td height="20" colspan="3" align="left"><img src="images/vote_logo.gif" width="185" height="42"></td>
  </tr>
  <tr class="tdbg"><td><table width="480" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#cccccc">
              <tr bgcolor="#ffffff"> 
                <td width="81" align="center" nowrap>调查内容</td>
                <td colspan="2"><%=rsvote("title")%></td>
              </tr>
              <tr bgcolor="#ffffff"> 
                <td align="center" nowrap>总投票数</td>
                <td colspan="2">  
                  <%
  dim totalvote
  totalvote=0
  for i=1 to 8
  	if rsvote("select" & i)="" then exit for
	totalvote=totalvote+rsvote("answer"& i)
  next
  response.write(totalvote & "票")
  if totalvote=0 then totalvote=1
  %>
                </td>
              </tr>
              <tr bgcolor="#ffffff"> 
                <td colspan="3" align="center">&nbsp;</td>
              </tr>
              <tr bgcolor="#ffffff"> 
                <td align="center" nowrap>投票选项</td>
                <td width="48" align="center" nowrap> 票数</td>
                <td width="317" align="center">百 分 比</td>
              </tr>
              <%
  for i=1 to 8
  	if trim(rsvote("select" & i) & "")="" then exit for
  %>
              <tr bgcolor="#ffffff"> 
                <td align="center"> <%=rsvote("select"& i)%> </td>
                <td align="center"> 
                  <%
	response.write rsvote("answer"& i)
	%>
                </td>
                <td> 
                  <%
	dim pervote
	pervote=round(rsvote("answer"& i)/totalvote,4)
	response.write "<img src='images/bar.gif' width='"&round(360*pervote)&"' height='10' align='absmiddle'>"
	pervote=pervote*100
	if pervote<1 and pervote<>0 then
		response.write "&nbsp;0" & pervote & "%"
	else
		response.write "&nbsp;" & pervote & "%"
	end if
	%>
                </td>
              </tr>
              <% next %>
            </table></td>
  </tr>
</table>
      <%
if session("voted")="" then 
	    response.write "<script>alert('您还没有投票,希望您能投上一票!');</script>"
end if
%>
      <br><input class="button" type="button" value="关闭" onclick="javascript:window.close();"></td>
  </tr>
</table>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -