Create a simple online survey with file writing

Source: Internet
Author: User
Believe that there is a personal homepage of netizens, is not very interested to know how visitors evaluate their work, so as to give themselves a direction of improvement, the following online survey is one example:

You need to support the FSO space, just two files, one is the processing of the page poll.asp, there is a data file Poll.txt, of course, there is a page to show the submission of the form, the following are given the code:

1. Poll.asp:

<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Site Survey </title>
<link href= "News1.css" rel= "stylesheet" type= "Text/css" >
<body>
<p>
<%
Dim polled,total
Dim Pollper (4)
Dim Pollname (7)
Dim Pollnum (4)
Polled=cint (Request.Form ("select"))
Set fs= Server.CreateObject ("Scripting.FileSystemObject")
Poll=server. MapPath ("Poll.txt")
Set Textar=fs.opentextfile (poll,1,0,0)
If not session (polled) then
I=0
While not Textar.atendofstream
Getdata=textar.readline
Pollname (i) =left (RTrim (GetData), 7)
Pollnum (i) =right (RTrim (GetData), 4)
If I=polled Then
J=cdbl (Pollnum (i)) +1
Pollnum (i) =right (space (6) &trim (CStr (j)), 7)
End If
I=i+1
Wend
Textar.close
Set Textar1=fs.createtextfile (poll,-1,0)
Totle=0
For J=0 to (I-1)
Total=total+cdbl (Pollnum (j))
Textar1.writeline Pollname (j) &pollnum (j)
Next
Textar1.close
%>
<span class= "News1" > Where do you think this site needs improvement? </span></p>
<%
For J=0 to (I-1)
Pollper (j) =cdbl (Pollnum (j))/total
Width=500*pollper (j)
%>
<table width= "750" border= "0" align= "left" >
<tr>
&LT;TD align= "left" bgcolor= "#CCCCCC" >
<%response.write (Trim (Pollname (j)) & "(")
Response.Write (FormatNumber (Pollnum (j), 0) & ")"
Response.Write ("<br>")
Response.Write ("Response.Write (width& "' height=10>")
Response.Write (FormatPercent (Pollper (j)) & "<p>")
Next
Response.Write ("Total:")
Response.Write (FormatNumber (total,0))
%>
</td>
</tr>
</table>
<%
Session (polled) =true
Else
Response.Write ("You have already voted, thank you for your vote!") ")
End If
%>
<p> </p>
</body>

2.poll.txt:

Page Art 27
Coverage of content 35
Update speed of content 43
Site visits 53

The page you want to display (form):

<table width= "100%" height= "215" border= "0" bordercolor= "#FFFFFF" background= "%20" >
<tr>
&LT;TD height= "align=" "Center" background= "Http://www.163design.net/a/y/images/bg1.gif" class= "1" > Where do you think the site needs improvement? </td>
</tr>
<tr>
&LT;TD height= "bgcolor=" "#FFFFFF" class= "1" > <input name= "select" type= "Radio" value= "0" checked>
The art of the page </td>
</tr>
<tr>
&LT;TD height= "background=" "bgcolor=" #FFFFFF "class=" 1 ">
<input type= "Radio" name= "select" value= "1" >
Content Coverage </td>
</tr>
<tr>
&LT;TD height= "bgcolor=" "#FFFFFF" class= "1" > <input type= "Radio" name= "select" value= "2" >
Update speed of content </td>
</tr>
<tr>
&LT;TD height= "background=" "bgcolor=" #FFFFFF "class=" 1 ">
<input type= "Radio" name= "select" value= "3" >
Site visits </td>
</tr>
<tr>
&LT;TD height= "align=" center "bgcolor=" #FFFFFF &qu



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.