USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  ASP - Active Server Page
Voltar
Autor Assunto:  Enquetes
Paulo Eduardo
não registrado
Postada em 16/05/2005 11:23 hs   
Olá, como posso desenvolver uma enquete para web utilizando ASP, incluindo akeles gráficos para melhor definição dos resultados e a porcentagem de votos.
Obrigado
Aguardo respostas.
     
Martini
Pontos: 2843 Pontos: 2843
PAROBÉ
RS - BRASIL
Postada em 17/05/2005 10:20 hs         

tabelas:
Enquetes
 Codigo da enquete
 Pergunta
 Ativo
Enquetes_alternativas
 Codigo da enquete
 Codigo da alternativa
 Votos

em um form coloque as alternativas, onde você vai selecionar a enquete que estiver
ativa, o valor de cada opção o código da alternativa (tudo dinâmico, ou seja, no início
da página você seleciona a enquete ativa e depois coloca os textos da pergunta e das
alternativas) exemplo:


      <table width="100%" height="126" border="0">
        <tr>
          <td width="65%" height="126" class="BordaTabelaTraco">&nbsp;</td>
          <td width="35%" height="126" valign="top">
<form action="Enquete_Resultado.asp?Enquete=8" method="post" name="form1" target="Default_principal">
              <table width="100%" height="126" bgcolor="#E1F7FD">
               
                <tr>
                  <td height="25" colspan="2"><font class="TextoPadraoPreto10"><strong>
                    Quem é mais bonita?
                    </strong></font></td>
                </tr>
                <tr>
                  <td width="15%" height="25">
                    <input type="radio" name="Alternativa" value="16">
                  </td>
                  <td width="85%" height="25"><font class="TextoPadraoPreto10">
                    Angelina Jolie
                    </font></td>
                </tr>
                <tr>
                  <td height="25">
                    <input type="radio" name="Alternativa" value="17">
                  </td>
                  <td height="25"><font class="TextoPadraoPreto10">
                    Julia Robets
                    </font></td>
                </tr>
                <tr>
                  <td height="25">
                    <input type="radio" name="Alternativa" value="18">
                  </td>
                  <td height="25"><font class="TextoPadraoPreto10">
                    Nicole Kidman
                    </font></td>
                </tr>
                <tr>
                  <td height="26" colspan="2" align="center">
                    <input type="submit" name="Submit" value="Votar" class="Botao">
                  </td>
                </tr>
              </table>
            </form></td>
        </tr>
      </table>

 


este é o arquivo que recebe as informações enviadas pelo usuário,
eu uso um gif para mostrar graficamente o resultado parcial,
"Enquete_Resultado.asp"


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Conexao_bd.asp" -->
<%
 on error resume next
  Dim SQL, rst, Alternativa, Enquete, rst1, SQL1, TotalVotos
 Alternativa = Request("Alternativa")
 Enquete = request("Enquete")
 vgdb.execute "Update Enquetes_alternativas Set Votos = Votos + 1 Where Enquetes_alternativas.[Codigo da alternativa] = " & Alternativa
 SQL = "SELECT Enquetes.[Codigo da enquete], Enquetes.Pergunta, Enquetes_alternativas.[Codigo da alternativa], Enquetes_alternativas.Alternativa, Enquetes_alternativas.Votos FROM Enquetes INNER JOIN Enquetes_alternativas ON Enquetes.[Codigo da enquete] = Enquetes_alternativas.[Codigo da enquete] WHERE (((Enquetes.[Codigo da enquete])=" & Enquete & ")) ORDER BY Enquetes_alternativas.[Codigo da alternativa];"
  Set rst = server.createobject("adodb.recordset")
  rst.open SQL, vgdb, 1, 1 
 if rst.eof then
      rst.close
   set rst = nothing
   Response.Write(Default.asp)
 end if 
 'total votos
 SQL1 = "SELECT Sum(Enquetes_alternativas.Votos) AS SomaDeVotos FROM Enquetes_alternativas WHERE (((Enquetes_alternativas.[Codigo da enquete])=" & Enquete & "));"
  Set rst1 = server.createobject("adodb.recordset")
  rst1.open SQL1, vgdb, 1, 1 
 if rst1.eof then
   TotalVotos = 0
 else
   TotalVotos = rst1("SomaDeVotos")
 end if
%>
<html>
<style type="text/css">
<!--
BODY {
 SCROLLBAR-FACE-COLOR: #2769AB;
 SCROLLBAR-HIGHLIGHT-COLOR: #0099FF;
 SCROLLBAR-SHADOW-COLOR: #0099FF;
 SCROLLBAR-3DLIGHT-COLOR: #0099FF;
 SCROLLBAR-ARROW-COLOR:  #0099FF;
 SCROLLBAR-TRACK-COLOR: #ffffff;
 SCROLLBAR-DARKSHADOW-COLOR: #ffffff;
}
-->
</style>
<head>
<link rel="stylesheet" href="./Estilos.css" type="text/css">
<title>Resultado da Enquete - Locadora de Filmes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
 
<body leftmargin="2" topmargin="2" marginwidth="22">
<table width="604" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="BordaBaixa"><font class="TextoPadraoAzulEscuro"><strong>Resultado Parcial da Enquete</strong></font></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table>
      <table width="100%" border="0">
        <caption><font class="TextoPadraoPreto">
        <% = rst("Pergunta") %></font>
        </caption>
        <tr>
          <td><img src="Figuras/gra_base.gif" width="11" height="25"><img src="Figuras/gra_centro.gif" width="<% = rst("Votos") %>" height="25"><img src="Figuras/gra_topo.gif"><font class="TextoPadraoPreto">
            <% = rst("Alternativa") %>
            -
            <% = (int(((rst("Votos") * 100) / TotalVotos) * 10) / 10) %>
            %</font></td>
        </tr>
        <tr>
          <%
      rst.movenext
     %>
          <td><img src="Figuras/gra_base.gif" width="11" height="25"><img src="Figuras/gra_centro.gif" width="<% = rst("Votos") %>" height="25"><img src="Figuras/gra_topo.gif"><font class="TextoPadraoPreto">
            <% = rst("Alternativa") %>
            -
            <% = (int(((rst("Votos") * 100) / TotalVotos) * 10) / 10) %>
            %</font></td>
        </tr>
        <tr>
          <%
      rst.movenext
     %>
          <td><img src="Figuras/gra_base.gif" width="11" height="25"><img src="Figuras/gra_centro.gif" width="<% = rst("Votos") %>" height="25"><img src="Figuras/gra_topo.gif"><font class="TextoPadraoPreto">
            <% = rst("Alternativa") %>
            -
            <% = (int(((rst("Votos") * 100) / TotalVotos) * 10) / 10) %>
            %</font></td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td align="right" class="BordaAlta"><a href="javascript:history.back()" class="LinkPadraoLista">Voltar</a></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
<% 
  rst.close
 set rst = nothing
  rst1.close
 set rst1 = nothing 
%>

 
     
Página(s): 1/1    


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2025   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página