dcsimg

Online Survey Form Administration

By ServerWatch Staff (Send Email)
Posted Jun 6, 1999


by Jessie Cui

In most web_based database application, webmasters are allowed to administrate their web sites throuth internet. In that way webmaster can maintain database or modify html pages anywhere. Many company's  internet or intranet site has both back end (for adminstration) and front end (for site visitors). This artical is just quick example to display survey form on front end and update survey questions on back end. Below is table showing asp pages and database I will demo in this presentaion.

File Name: File Type: Description:
1)   survey.asp asp file, on front end survey form
2)  surveyfb.asp asp file, on front end respond to submitting survey form
3)  *surveyForm.asp asp file, on back end modify survey questions
4)  *surveyAction.asp asp file, on back end redirect to pages based on user's action
5)  *surveyList.asp asp file, on back end survery questions list
6)  global.asa asa file set session variable, data connection string.
7)  jcSurvey.mdb Access database (3 tables) Survey tbl, SurveyRep tbl and SurveyAnsType tbl.
8)  jcSurvey.zip zip file for download first seven files in this zip file
* Created by Visual InterDev (1.0) wizard.
In most web_based database application, webmasters are allowed to administrate their web sites throuth internet. In that way webmaster can maintain database or modify html pages anywhere.

Demo

Download    jcSurvey.zip

Survey.asp dynamicly generates survey questions and selections of each question or textarea form based on table Survey of jcSurvey.mdb. You can go to SurveyForm.asp on back end to modify survey question. All survey questions on front end are not published until their related 'publish flags' are turned on on back end. After publishing, new survey questions can be viewed by reloading o Survey.asp.


<%@ LANGUAGE="VBSCRIPT" %>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Survey Page</TITLE>
</HEAD>
<BODY>
<center><font color="RED"><h3>JC Survey Form</h3></font></center>

<%
Set jcSurvey = Server.CreateObject("ADODB.Connection")
jcSurvey.ConnectionTimeout = Session("jcSurvey_ConnectionTimeout")
jcSurvey.CommandTimeout = Session("jcSurvey_CommandTimeout")
jcSurvey.Open Session("jcSurvey_ConnectionString"), Session("jcSurvey_RuntimeUserName"), Session("jcSurvey_RuntimePassword")
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set rs = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText = "SELECT ID, Subject, Description, Answer1, Answer2, Answer3, Answer4, Answer5, AnsType, DatePosted, Publish FROM Survey where Publish<>0"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = jcSurvey
rs.Open cmdTemp, , 1, 1
%>


<uL>
<form action="surveyfb.asp" method="post" name="sv">
<font color="#800000"><strong>
<%
rs.movefirst
do
%><font color="#800000"><strong>
<%
response.write "<li>" & rs("Description") & "<hr>"
%>

</strong></font>
<%
dim i
for i=3 to 7                            ' Answer1 to Answer5
    if not(rs(i)=null) or not rs(i)="" then
    %>
    <input type="<%=rs("AnsType")%>" name="<%response.write rs("ID")%>" value="<%=(i-2)&rs(i)%>">  
    <font color="#000000"><%response.write rs(i) %></font><br>

    <%end if
        if rs("AnsType")="textarea" then
    %>    <textarea name="<%=rs("ID")%>" rows="5" cols="50" ></textarea>   

    <% exit for
        end if
    response.write "</li>"
next
rs.movenext
loop until rs.eof or rs.bof
rs.close

%>

</ul><hr>
<input type="submit" value="Submit">
</form>
</BODY>
</HTML>

 


Surveyfb.asp is respond to submitting the previous page Survey.asp and save user's selections or answers to SurveyRep table. For demo purpose, here just display  "Thank you!" to tell user that his/her infomation has been stored into database. In addition, a confirm table may be used to display user's selections he just submitted on this page.


<%@ LANGUAGE="VBSCRIPT" %>
<html>
<head>
<title>Survey Response Page</title>
</head>
<body BGCOLOR="#FFFFFF">
<br><br><br>Thank you! Thank you! Thank you!
<%
Set jcSurvey = Server.CreateObject("ADODB.Connection")
jcSurvey.ConnectionTimeout = Session("jcSurvey_ConnectionTimeout")
jcSurvey.CommandTimeout = Session("jcSurvey_CommandTimeout")
jcSurvey.Open Session("jcSurvey_ConnectionString"), Session("jcSurvey_RuntimeUserName"), Session("jcSurvey_RuntimePassword")
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set rs = Server.CreateObject("ADODB.Recordset")
Application.lock
cmdTemp.CommandText = "SELECT SurveyId, Answer1Sel, Answer2Sel, Answer3Sel, Answer4Sel, Answer5Sel, TxtAnswer, DateLastAns, ID FROM SurveyRep "                 
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = jcSurvey
rs.Open cmdTemp, , 1, 4

For Each Item in Request.Form
    rs.addnew                                                ''' add user's selections to table SurveyRep
    rs(0)=Item
    rs("DateLastAns")=date()
    For intLoop = 1 to Request.Form(Item).Count
    dim fld
    dim opt
        opt=Request.Form(Item)(intLoop)
            if IsNumeric(left(opt, 1)) then              ' extract first digit from Form value="<%=(i-2)&rs(i)%>" as user's selection
                fld=cint(left(opt, 1))
            else
                fld=6                                             ' indicate form type is textarea
            end if
            rs(fld)=Request.Form(Item)(intLoop)
    Next
    rs.updateBatch
Next
rs.close
set rs=nothing
%>
</body>
</html>

 


SurveyForm.asp, SurveyList.asp and SurveyAction.asp are Created by Visual InterDev (1.0) wizard,   for administrating Survey form on back end. You also can create asp pages to administrate SurveyRep table.

See who is using Survey Form and some projects of my work.

GTE Supply    http://www.gtes.com/marketsurvey/indx_market.asp

ebCity.com    http://www.ebcity.com/jessie/xinwen/survey.asp

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.


 

 


Thanks for your registration, follow us on our social networks to keep up-to-date