<%@ Language=VBScript %> <% nopolls = "no" Dim RS, strSQL, strName Set RS = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT PollOptions.PollID AS optPollID, " & _ "PollOptions.PollText AS optPollText, PollOptions.UID as UID, Poll.PollID, Poll.PollName, " & _ "Poll.PollText, Poll.PollType, Poll.PollItemCount, Poll.StartDate, " & _ "Poll.EndDate, Poll.Image " & _ "FROM Poll INNER JOIN " & _ "PollOptions ON Poll.PollID = PollOptions.PollID " & _ "WHERE (StartDate <='" & date() & "' AND EndDate >= '" & date() & "') ORDER BY PollOptions.PolLText" 'Response.Write strSQL & "

" 'Response.End RS.Open strSQL, oConn, 1, 1 %> SA - HYPERTENSION VOTES

<%'--------------begin vote poll------------------------------------------------------------------------ if RS.RecordCount > 0 then %>
"> "> <% if Request.QueryString("Voted") = "Yes" then %> <% end if %> <% dim chkCounter 'Use this variable to assign integers to the checkboxes chkCounter = 2 'Start variable off on 2 and double it each time if rs("PollType") = 0 then 'If The Poll Type is singular then use radio buttons do while not RS.EOF or RS.BOF 'Loop through the records and assign radio buttons to each options %> <% RS.MoveNext loop else 'Else the Poll Type is multiple and checkboxes are required do while not RS.EOF or RS.BOF 'Loop through the records and assign checkboxes to each option %> <% RS.MoveNext chkCounter = chkCounter + chkCounter 'The next checkboxes value becomes double the previous one loop end if RS.MoveFirst ' Move back to the record so you can set the querystring for the view results %> <% if rs("Image") <> "" Then %> <% end if %>

You have already voted on this topic.

Vote
<%Response.Write rs("PollText")%>
<%=rs("optPollText")%> ">
<%=rs("optPollText")%> ">
<% thisPollid = rs("PollID")%>
" border="0">
<% else %>
There are currently no Polls to vote on.
<% nopolls = "yes" end if 'Response.Write date() RS.Close Set RS = nothing '- end vote poll -------------------------------------------------------------------------------%> <%'---begin poll results -----------------------------------------------------------------------%> <% if nopolls = "no" then Dim RSResults, strResultsSQL Set RS = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT *, Poll.PollID AS PollID, Poll.PollName AS PollName, " & _ "Poll.PollText AS PollText, PollOptions.PollText AS [Option], " & _ "PollOptions.UID AS Expr2 FROM Poll INNER JOIN " & _ "PollOptions ON Poll.PollID = PollOptions.PollID " & _ "WHERE (Poll.PollID = " & thisPollid & ") ORDER BY PollOptions.PolLText" RS.Open strSQL, oConn, 1, 1 Set RSResults = Server.CreateObject("ADODB.Recordset") strResultsSQL = "SELECT * FROM PollChoices WHERE (PollID = " & thisPollid & ")" RSResults.Open strResultsSQL, oConn, 1, 1 %> <% if RSResults.RecordCount > 0 then %> <% Dim intCounter, intOptionCounter, intPercent, intTotalVotes intTotalVotes = 0 Do while not rs.EOF or rs.BOF %> <% rs.MoveNext loop %>
Vote results
<%=rs("PolLText")%>
<%=rs("option")%> <% intCounter = 0 RSResults.MoveFirst do while not RSResults.EOF or RSResults.BOF if CInt(RSResults("Choice")) = CInt(rs("UID")) then intCounter = intCounter + 1 end if %> <% RSResults.MoveNext loop %> <% 'intPercent = FormatNumber(intCounter / RSResults.RecordCount * 100,0) 'for i = 0 to intPercent ' Response.Write "" 'next intTotalVotes = intTotalVotes + intCounter %>
 
<%Response.Write intCounter & "(" & (round(100 / RSResults.RecordCount)) * intCounter & "%)"%>
<%Response.Write intTotalVotes%> <%if Cint(intTotalVotes) =1 then response.write " Person" else response.write " People" end if %> have voted on this poll.


<% else %>
Vote results
There have been no votes on this topic yet
<% end if %> <% RS.Close Set RS = nothing end if %> <%'---end poll results------------------------------------------------------------------------------%>