%
dim Action,ID,VoteType,VoteOption,arrOptions,sqlVote,rsVote
dim Voted,VotedID,arrVotedID,i
dim FoundErr,ErrMsg
Action=trim(Request("Action"))
ID=Trim(request("ID"))
VoteType=Trim(request("VoteType"))
VoteOption=trim(request("VoteOption"))
Voted=False
VotedID=session("VotedID")
if Id="" then
founderr=true
errmsg=errmsg+"
不能确定调查ID
"
call WriteErrMsg()
response.end
else
ID=CLng(ID)
if instr(VotedID,",")>0 then
arrVotedID=split(VotedID,",")
for i=0 to ubound(arrVotedID)
if Clng(arrVotedID(i))=ID then
Voted=True
exit for
end if
next
else
if VotedID=ID then
Voted=True
end if
end if
end if
if Action="" or VoteOption="" then
Action="Show"
end if
If Action = "Vote" And VoteOption<>"" and Voted=False Then
if VoteType="Single" then
conn.execute "Update Vote set answer" & VoteOption & "= answer" & VoteOption & "+1 where ID=" & ID
else
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 if
if VotedID="" then
session("VotedID")=ID
else
session("VotedID")=VotedID & "," & ID
end if
End If
sqlVote="Select * from Vote Where ID=" & ID
Set rsVote = Server.CreateObject("ADODB.Recordset")
rsVote.open sqlVote,conn,1,1
%>
调查结果
<%
if Action="Vote" And VoteOption<>"" then
response.write ""
if Session("UserName")<>"" then response.write Session("UserName") & ","
if Voted=True then
response.write "== 你已经投过票了,请勿重复投票! =="
else
response.write "== 非常感谢您的投票! =="
end if
response.write " "
end if
%>
网站关于“<%=rsVote("Title")%>”的调查结果
·目前网友的总投票数为:
<%
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
%>
<%
for i=1 to 8
if trim(rsVote("Select" & i) & "")="" then exit for
%>
<% next %>
<%
for i=1 to 8
if trim(rsVote("Select" & i) & "")="" then exit for
%>
占:<% if perVote<1 and perVote<>0 then
response.write " 0" & perVote & "%"
else
response.write " " & perVote & "%"
end if
%>
[得:<%response.write rsVote("answer"& i)%>票]
<% next %>
<%
if Action="Show" and Voted=False then
if Session("UserName")<>"" then
response.write Session("UserName") & ","
end if
response.Write " 您还没有投票,请您在此投下您宝贵的一票!"
response.write ""
end if
dim sqlOtherVote,rsOtherVote
if session("VoteID")<>"" then
sqlOtherVote="Select * from Vote Where ID Not In (" & session("VotedID") & ") order by ID desc"
else
sqlOtherVote="select * from Vote where ID<>" & ID
end if
Set rsOtherVote = Server.CreateObject("ADODB.Recordset")
rsOtherVote.open sqlOtherVote,conn,1,1
if rsOtherVote.bof and rsOtherVote.eof then
response.write " 感谢您参加了本站的所有调查!!!"
else
response.write " 欢迎你继续参加本站的其他调查: