Jump to content


Photo

Enquete


  • Faça o login para participar
2 replies to this topic

#1 Squila

Squila

    Novato no fórum

  • Usuários
  • 16 posts
  • Sexo:Não informado

Posted 06/07/2004, 12:26

Um dia eu aprendo..rss

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.

Onde quer que você vá, vá com todo o coração. (Confúcio)

#2 Fernando_Ramos

Fernando_Ramos

    Fernando Ramos

  • Usuários
  • 728 posts
  • Sexo:Não informado

Posted 06/07/2004, 12:32

ao final do voto coloque

response.write "<script>window.close();</script>"


--
www.ramosinformatica.com
contato@ramosinformatica.com | @rinformatica

Hospedagem de site | Desenvolvimento de Sistemas | Informática em Geral

#3 Squila

Squila

    Novato no fórum

  • Usuários
  • 16 posts
  • Sexo:Não informado

Posted 06/07/2004, 14:18

Muito Obrigadaaa!!!

Deu certinhooo!!!!

O q seria de mim sem vocês...rsss

Beijos gordos

Edição feita por: Squila, 06/07/2004, 14:18.

Onde quer que você vá, vá com todo o coração. (Confúcio)




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq