How to use ASP to establish a voting mechanism on your own website (i)
Source: Internet
Author: User
Batman Translation Finishing
A very good ASP program to build your own voting system. Read it carefully, and as long as you can understand the key technologies in the middle, you can build your own polling station on your website. The papers were hastily sorted out and I hope you will understand.
All rights reserved:
ASP Polls
Version 1.0
Tipped Cow Development and adrenalin Labs
Structure Simple Introduction:
Access database design structure:
Poll table primary field name: Pollname,pollcreator,pollquestion,password,choice1,choice2
Choice3,choice4,choice5,id (AutoNumber), GetName
Pollresults table fields: Pollid,pollanswer,name
1. Document Db.inc
<%
Application ("asp_poll") = "Asp_poll"
cnstring = "Driver={microsoft Access DRIVER (*.mdb)};"
cnstring = cnstring & "dbq=" & Server.MapPath ("Events.mdb")
Application ("asppolldsn") = cnstring
%>
1. Document Creat_poll1.asp
<% title= "Poll Generator"%>
<title><%=Title%></title>
<body>
<div align= "left" ><br" >another Joint product from <a href= "Http://www.ncws.com/tippycow" >tipped Cow development</a> and <a href= "http://dstoflet.calweb.com" >adrenalin labs</a>
<br><br>
</div>
<center>
<%
Response.Write "<font face= ' Arial ' >"
If Request ("errormessage") <> "Then
Response.Write "<b>error! </b> "& Request (" ErrorMessage ")
Else
Response.Write "Please complete the form below to begin creating your own."
End If
%>
<table border=0 cellspacing=0 cellpadding=10 width=500><tr>
<TD colspan=2 bgcolor= #000000 align=center class= "Bold2" >
Create a Password for Your Poll and Can Modify It at a
Later time
</td>
</tr><tr>
<TD bgcolor= #ffffff width=25% class= "bold" >poll Admin password:</td>
<TD bgcolor= #ffffff >
<input type= "password" name= "password" value= <%=request ("password")%> "size=10 maxlength=10 Class=input>
</td>
</tr>
</table>
</td></tr>
<tr><td>
<table border=0 cellspacing=0 cellpadding=10 width=500><tr>
<TD colspan=2 bgcolor= #000000 align=center class= "Bold2" >
Give Your Poll a Unique Name
</td>
</tr><tr>
<TD bgcolor= #ffffff width=25% class= "bold" >poll name:</td>
<TD bgcolor= #ffffff >
<input type= "text" name= "name" value= "<%=request (" name ")%>" Size=20 class=input>
</td>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=10 width=500><tr>
<TD colspan=2 bgcolor= #000000 align=center class= "Bold2" >
Do your want to have the user enter their name?
</td>
</tr><tr>
<TD bgcolor= #ffffff width=25% class= "bold" >require user to enter their name:</td>
<TD bgcolor= #ffffff class= "Bold" >
Yes<input type= "Radio" name= "GetName" value= "1" ><br>
No <input type= "Radio" name= "GetName" value= "0" checked>
</td>
</tr>
</table>
<%
Total = 0
For I=1 to 5
Responsecount = Responses (I)
If responsecount <> "" Then
Total = Total + Cint (responsecount)
End If
Next
For I=1 to 5
Choice = Choices (I)
Responsecount = Responses (I)
If choice <> "" Then
Response.Write "<tr><td colspan=1 align=left><font face= ' Arial ' >"
Response.Write Choice
Response.Write "</td>"
Response.Write "<td colspan=2 width=400><table border=1 cellspacing=0><tr><td bgcolor=blue Align =center width= "& Converttopix (Responsecount) &" ><font face= ' ms Sans Serif ' color=white><b> ' & Amp Converttopercent (Responsecount) & "</td></tr></table></td>"
Response.Write "</tr>"
End If
Next
Function Converttopix (SZ)
If Sz = 0 Then
Converttopix = 0
Else
Converttopix = Cint (400/total * sz)
End If
End Function
Function converttopercent (SZ)
If Sz = 0 Then
Converttopercent = "0%"
Else
Converttopercent = FormatPercent (sz/total, 2)
End If
End Function
%>
</table>
<% If num = "" Then%>
<br><br>
<table border=0 cellspacing=0 cellpadding=0><tr>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service