<%
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open application ("Asppolldsn")
sql = "SELECT * from Poll where id =" & ID
Set RS = conn. Execute (SQL)
If Rs. EOF = False Then
%>
Sub Application_OnStart
Application ("asp_poll") = "Asp_poll"
cnstring = "Driver={microsoft Access DRIVER (*.mdb)};"
cnstring = cnstring & "dbq=" & Server.MapPath ("Events.mdb")
Application ("asppolldsn") = cnstring
End Sub
</SCRIPT>
6. Document Pool.inc
<%
DBPath = Server.MapPath ("/poll/events.mdb")
ID = 28
If request.cookies ("pollid") = CStr (ID) Then
Showdisplay
Else
Showvote
End If
Function converttopercent (Total, SZ)
If Sz = 0 Then
Converttopercent = "0%"
Else
Converttopercent = FormatPercent (sz/total, 2)
End If
End Function
Sub Showvote
%>
<div align=right>
<table width=125 border=1 cellspacing=0 cellpadding=0><tr><td>
<form method= "POST" action= "/poll/collect.asp" >
<input type= "hidden" name= "id" value= "<%=id%>" >
<input type= "hidden" name= return_page "value=" <%=request.servervariables ("Path_info")%> ">
<%
Set conn = Server.CreateObject ("ADODB. Connection ")
Dsnpath = "Driver={microsoft ACCESS DRIVER (*.mdb)};"
Dsnpath = Dsnpath & "dbq=" & DBPath
Conn.Open Dsnpath
sql = "SELECT * from Poll where id =" & ID
Set RS = conn. Execute (SQL)
If Rs. EOF = False Then
%>
<table width=125 border=0 cellspacing=0 cellpadding=2 bgcolor= #4f4f4f >
<tr>
<TD colspan=3 bgcolor= #2f2f4f align=center>
<%=rs ("Pollquestion")%>
</td>
</tr>
<%
For I=1 to 5
Choice = rs ("Choice" & I)
If choice <> "" Then
%>
<tr>
<TD colspan=2 bgcolor= #000000 valign=top width=80%>
<%=choice%> </td><td valign=top colspan=1 width=20% bgcolor= #000000 > <input type= "Radio" name= " Choice "value=" <%=I%> ">
</td></tr>
<%
End If
Next
%>
<tr>
<TD colspan=3 align=center bgcolor= #2f2f4f align=right>
<input type= "Submit" value= "Submit" class=nav>
</td></tr>
</table>
<%
End If
%>
</td></tr></form></table>
</center>
<%
End Sub
Sub Showdisplay
Set conn = Server.CreateObject ("ADODB. Connection ")
sql = "SELECT * from Poll where id =" & Cint (ID)
Dsnpath = "Driver={microsoft ACCESS DRIVER (*.mdb)};"
Dsnpath = Dsnpath & "dbq=" & DBPath
Conn.Open Dsnpath
Set rs = conn.execute (SQL)
If Rs. EOF = False Then
Dim Choices (6)
Dim Responses (6)
For I=1 to 5
Choice = rs ("Choice" & I)
Choices (I) = Choice
If choice <> "" Then
Set conn2 = Server.CreateObject ("ADODB. Connection ")
sql = "Select COUNT (pollanswer) from pollresults where Pollid =" & Cint (ID) & "and pollanswer=" & I
Dsnpath = "Driver={microsoft ACCESS DRIVER (*.mdb)};"
Dsnpath = Dsnpath & "dbq=" & DBPath
Conn2.open Dsnpath
Set rs2 = conn.execute (SQL)
If rs2. EOF = False Then
Responses (I) = rs2 (0)
End If
Rs2. Close
Conn2. Close
End If
Next
%>
<div align= "Right" >
<table border=1 cellspacing=0 cellpadding=2><tr><td>
<table width=125 border=0 cellspacing=0><tr>
<TD colspan=2 bgcolor= #2f2f4f align=center class=orgbold>asp Poll
</td></tr>
<TR><TD colspan=2 align=center bgcolor= #ccccff class=black>
Q:<%=rs ("Pollquestion")%>
</td></tr>
<%
Total = 0
For I=1 to 5
Responsecount = Responses (I)
If responsecount <> "" Then
Total = Total + Cint (responsecount)
End If
Next
For I=1 to 5
Choice = Choices (I)
Responsecount = Responses (I)
If choice <> "" Then
Response.Write "<tr><td colspan=1 align=left><font face= ' Verdana ' size=-1 color= #f0f0f0 >"
Response.Write Choice
Response.Write "</td>"
Response.Write "<td>" & Converttopercent (Total, Responsecount) & "</td>"
Response.Write "</tr>"
End If
Next
Response.Write "</table></td></tr></table></div>"
End If
End Sub
%>
</div>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.