The specific voting procedure implemented by ASP

Source: Internet
Author: User
Tags key readline
Program | vote

Function: Vote on the software and computer studio columns, choose your favorite columns.

Implementation method: The results of the vote exist in the Result.txt file, the current working page is voting.asp, the object submitted is voted.asp, when you click the View button, you can view the results of the current ballot. The bug in the middle is that when you submit, you continue to refresh the voted.asp, so that the ballot results are automatically added, think about why? What is the way to solve it? You've met a similar website.

The key to Voting.asp is:

1: Show viewing results

<script language=javascript>
function Windowopen (Loadpos)
{window.open (Loadpos, "Surveywin", "toolbar,resizable,scrollbars,dependent,width=400,height=480");
}
</SCRIPT>

2: Submit data to voted.asp <form method= "POST" action= "voted.asp" >

3:voted.asp's key is to the following two sentences, the first line is to save the number of software column votes, the second line is to save the number of votes in the computer Studio column. The next procedure is to automatically update the number of votes in the software column or the number of votes in the computer studio column based on the data submitted.

<%
Set files= Server.CreateObject ("Scripting.FileSystemObject")
If Request.Form ("R1") = "Soft" Then
Set filer= Files.opentextfile (Server.MapPath ("Result.txt"), 1, True)
Soft = Filer.readline
Studio = Filer.readline
Filer.close

Soft=int (Soft) +1
Set filer= Files.opentextfile (Server.MapPath ("Result.txt"), 2, True)
Filer.writeline Soft
Filer.writeline Studio
Filer.close
Else
Set filer= Files.opentextfile (Server.MapPath ("Result.txt"), 1, True)
Soft = Filer.readline
Studio = Filer.readline
Filer.close

Studio=int (Studio) +1
Set filer= Files.opentextfile (Server.MapPath ("Result.txt"), 2, True)
Filer.writeline Soft
Filer.writeline Studio
Filer.close
End If
%>

4: The following procedure gets the number of votes in two columns, calculating the percentages and the number of votes.

<%
Set files= Server.CreateObject ("Scripting.FileSystemObject")
Set filer= Files.opentextfile (Server.MapPath ("Result.txt"), 1, True)
Osoft=filer.readline
Ostudio=filer.readline
Filer.close

ncount = Int (osoft) +int (Ostudio)
soft= (M int (osoft))/int (ncount)
studio= (M int (ostudio))/int (ncount)

Soft = FormatNumber (Soft, 2)
Studio = FormatNumber (Studio, 2)
%>



Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.