<%
dim action,id,v,chk,ltime,v_cbox,idd,t_interval,t_intervaltype,vvv,vv
dim i,rs1,rs2,rs3,iscomment,asum,i_count,disbf,VoteOption,sqlVote
action=request.QueryString("action")
select case action
case "exevote"
id=request.form("id")
idd=request.form("idd")
t_intervaltype=request.form("t_intervaltype")
t_interval=request.form("t_interval")
chk=request.form("chk")
VoteOption=trim(request("VoteOption"))
if request.cookies("idd")=idd then
response.write ""
response.end
end if
if not isnumeric(id) then
response.write ""
response.end
end if
select case chk
case "Single" '单选
conn.execute "Update Vote set answer" & VoteOption & "= answer" & VoteOption & "+1 where ID=" & id
case "Multi" '多选
dim arrOptions
if instr(VoteOption,",")>0 then
arrOptions=split(VoteOption,",")
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 select
response.cookies("idd")=idd
select case t_intervaltype
case "min"'分钟
response.cookies("idd").expires=date+(0.007*clng(t_interval))
case "hour"'小时
response.cookies("idd").expires=date+(0.042*clng(t_interval))
case "day"'天
response.cookies("idd").expires=date+(1*clng(t_interval))
end select
response.write ""
response.end
%>
<%
case "vote"'投票显示
%>
<%
case "viewvote"
id=request.querystring("id")
if not isnumeric(id) then
response.write ""
response.end
end if
%>
<%
sqlVote="Select * from Vote Where ID=" & Clng(ID)
Set rsVote = Server.CreateObject("ADODB.Recordset")
rsVote.open sqlVote,conn,1,1
dim totalVote
totalVote=0
for i=1 to 8
if rsVote("Select" & i)="" then exit for
totalVote=totalVote+rsVote("answer"& i)
next
if totalVote=0 then totalVote=1
%>
<%=rsVote("Title")%>
目前共有<%=totalVote%>人参予了投票
<%
for i=1 to 8
if trim(rsVote("Select" & i) & "")="" then exit for
%>
<%
dim perVote
perVote=round(rsVote("answer"& i)/totalVote,4)
perVote=perVote*100
if perVote<1 and perVote<>0 then
response.write " 0" & perVote & "%"
else
response.write " " & perVote & "%"
end if
%>
<% next %>
<%
end select
rsVote.Close()
Set rsVote = Nothing
call CloseConn()
%>