29/01/2010, 02:07
|
| | Fecha de Ingreso: marzo-2004 Ubicación: Madrid (España)
Mensajes: 837
Antigüedad: 20 años, 8 meses Puntos: 9 | |
Respuesta: Llamada encuesta asp Aqui esta el codigo
<%
u_input=request.form("u_input")
u_ip=request.servervariables("remote_addr")
if u_input = "" then
%>
<form method="post" action="<%= request.servervariables("script_name") %>">
<p class="izquierda">¿Que te parece la web?<br>
<input type="radio" value="1" name="u_input" checked >Buena<br>
<input type="radio" value="2" name="u_input">Regular<br>
<input type="radio" value="3" name="u_input">Mala<br>
<input type="submit" value="Submit" ></p>
</form>
<%
else
accessdb="encuesta"
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
sql = "select ip from ballot where ip ='" & u_ip & "'"
rs.Open sql, cn
if rs.eof then
been_here_before="No"
end if
rs.close
if been_here_before = "No" then
sql = "insert into ballot (ip, selection" & u_input &") "
sql = sql & "values ('" & u_ip & "',1)"
rs.Open sql, cn
end if
sql= "select distinctrow "
sql= sql & "sum(selection1) as sum_selection1, "
sql= sql & "sum(selection2) as sum_selection2, "
sql= sql & "sum(selection3) as sum_selection3, "
sql= sql & "count(*) AS total_votes "
sql= sql & "FROM ballot;"
rs.Open sql, cn
total1=rs ("sum_selection1")
total2=rs ("sum_selection2")
total3=rs ("sum_selection3")
count=rs ("total_votes") %>
<p class="izquierda">
¿Que te parece la web?<br>
<img src="green.jpg" height="10" width="<%= formatnumber((total1/count)*100,0) %>">
<%= formatnumber((total1/count)*100,1) %>%<br> Buena <br>
<img src="blue.jpg" height="10" width="<%= formatnumber((total2/count)*100,0) %>">
<%= formatnumber((total2/count)*100,1) %>%<br> Regular <br>
<img src="red.jpg" height="10" width="<%= formatnumber((total3/count)*100,0) %>">
<%= formatnumber((total3/count)*100,1) %>%<br> Mala <br>
Total Votos: <%= formatnumber(count,0,0) %><br> <% end if %> </p> |