Olá pessoal, consegui fazer uma enquete pro meu site!
Só que tem um problema eu queria que qdo a pessoa votasse a janela da enquete fechasse, ela ta puxando o resultado, e esse só eu preciso ver.
Alguem sabe? Muito Obrigada!!
Segue o codigo da janela para votar (votemaster.asp) e a do resultado(clsVoteMaster.asp)
<% Dim Voter Set Voter = New VoteMaster Voter.Database = "votemaster.mdb" If Len( Request.QueryString ) = 0 Then Voter.Group = 1 ElseIf Len( Request.QueryString( "group" ) ) > 0 Then Voter.Group = Request.QueryString( "group" ) End If If Len( Request.QueryString( "action" ) ) > 0 Then If Request.QueryString( "action" ) = "vote" Then Voter.Group = Request.QueryString( "group" ) Voter.Selection = Request.Form( "optVote" ) chk = Voter.Vote() If chk Then Response.Write( Voter.Results() ) ElseIf Not chk Then Response.Write( "Unable to process vote." ) End If Else Response.Write( Voter.Options() ) End If Else Response.Write( Voter.Options() ) End If Set Voter = Nothing %> <!-- #include file=clsVoteMaster.asp -->
<% End Sub Private Function Question() Set Con = Server.CreateObject( "ADODB.Connection" ) Con.Open( "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath( Database ) ) Set Rec = Con.Execute( "SELECT grpLbl FROM grpTable WHERE grpNum=" & CInt( Group ) ) grp = Rec( "grpLbl" ) Rec.Close Con.Close Set Con = Nothing Question = grp End Function Public Function Options() Set Con = Server.CreateObject( "ADODB.Connection" ) Con.Open( "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath( Database ) ) Set Rec = Con.Execute( "SELECT * FROM optTable WHERE optGrp=" & CInt( Group ) & " ORDER BY optLbl" ) While Not Rec.EOF data = data & "<li><input type=radio name=optVote value=" & Chr(34) & Rec( "optNum" ) & Chr(34) & ">" data = data & "<font face=tahoma size=2>" & Rec( "optLbl" ) & "</font></li>" & vbNewLine Rec.MoveNext Wend Rec.Close myd = "<form action=votemaster.asp?action=vote&group=" & Group & " method=post>" & vbNewLine & "<font face=tahoma size=2><b>" myd = myd & Question & "</b></font>" & vbNewLine & "<ol>" & vbNewLine & data & "</ol>" & vbNewLine myd = myd & "<dd><input type=submit value=Vote></dd>" & vbNewLine & "</form>" & vbNewLine Con.Close Set Con = Nothing Options = myd End Function Public Function Vote() If Len( Trim( Selection ) ) > 0 And IsNumeric( Selection ) Then Set Con = Server.CreateObject( "ADODB.Connection" ) Con.Open( "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath( Database ) ) Set Rec = Con.Execute( "SELECT optCnt FROM optTable WHERE optNum=" & CInt( Selection ) ) cnt = Rec( "optCnt" ) + 1 Rec.Close Con.Execute( "UPDATE optTable SET optCnt=" & cnt & " WHERE optNum=" & CInt( Selection ) ) Con.Close Set Con = Nothing Vote = True Else Vote = False End If End Function Public Function Results() Set Con = Server.CreateObject( "ADODB.Connection" ) Con.Open( "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath( Database ) ) Set Rec = Con.Execute( "SELECT * FROM optTable WHERE optGrp=" & CInt( Group ) & " ORDER BY optCnt DESC" ) While Not Rec.EOF data = data & "<li><font face=tahoma size=2>" & Rec( "optLbl" ) & ": <b>" & Rec( "optCnt" ) & "</b></font></li>" & vbNewLine Rec.MoveNext Wend Rec.Close data = "<font face=tahoma size=2><b>" & Question & "</b></font>" & vbNewLine & "<ol>" & vbNewLine & data & "</ol>" & vbNewLine Con.Close Set Con = Nothing Results = data End Function End Class %>
Edição feita por: Squila, 06/07/2004, 12:32.