473,396 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help Looping Through Survey Questions

I've create a simple survey using ASP. Its finished and
works, but one aspect of my coding is annoying me and I
cant figure out a better way of doing it.

Basically the questions are stored in an Access 2000 table
like this:

QUESTION_NUMBER QUESTION
1 Question 1 text....
2 Question 2 text....
3 Question 3 text....
4 Question 4 text....
5 Question 5 text....

My ASP page gets these questions and displays them in a
form dynamically. The user then answers the questions by
clicking radio buttons (Agree, Tend to agree, Not sure...
ect).

This works well and if I want to add a question I just
update the database table.

The problem is I've not been able to figure out how to
make the submit page dynamic. I'm having to manually add
code to my submit page to look after each question
individually rather than looping through the Form
collection.

For example when I build the SQL to update the database I
have to do it like this (note the last five lines look
after the responses to my five questions):

ReDim sqlValues(40)

sqlValues(0) = "values ("
sqlValues(1) = "'" & Session("emp_no") & "', "
sqlValues(2) = "'" & Session("Username") & "', "
sqlValues(3) = "'" & Session("sex") & "', "
sqlValues(4) = "'" & Session("phone") & "', "
sqlValues(5) = "'" & Session("job_title") & "', "
sqlValues(6) = "'" & Session("department") & "', "
sqlValues(7) = "'" & Session("age") & "', "
sqlValues(8) = "'" & Session("grade") & "', "
sqlValues(9) = "'" & Request.Form("1") & "', "
sqlValues(10) = "'" & Request.Form("2") & "', "
sqlValues(11) = "'" & Request.Form("3") & "', "
sqlValues(12) = "'" & Request.Form("4") & "', "
sqlValues(13) = "'" & Request.Form("5") & "', "
...

sql = Join(sqlValues)

Is there any possible way I can avoid having to hard code
the above and have the page work out what it needs to do
dynamically?

TIA,

Colin
Jul 19 '05 #1
4 1845
"Colin Steadman" <an*******@discussions.microsoft.com> wrote in message
news:21****************************@phx.gbl...
I've create a simple survey using ASP. Its finished and
works, but one aspect of my coding is annoying me and I
cant figure out a better way of doing it.

Basically the questions are stored in an Access 2000 table
like this:

QUESTION_NUMBER QUESTION
1 Question 1 text....
2 Question 2 text....
3 Question 3 text....
4 Question 4 text....
5 Question 5 text....

My ASP page gets these questions and displays them in a
form dynamically. The user then answers the questions by
clicking radio buttons (Agree, Tend to agree, Not sure...
ect).

This works well and if I want to add a question I just
update the database table.

The problem is I've not been able to figure out how to
make the submit page dynamic. I'm having to manually add
code to my submit page to look after each question
individually rather than looping through the Form
collection.

For example when I build the SQL to update the database I
have to do it like this (note the last five lines look
after the responses to my five questions):

ReDim sqlValues(40)

sqlValues(0) = "values ("
sqlValues(1) = "'" & Session("emp_no") & "', "
sqlValues(2) = "'" & Session("Username") & "', "
sqlValues(3) = "'" & Session("sex") & "', "
sqlValues(4) = "'" & Session("phone") & "', "
sqlValues(5) = "'" & Session("job_title") & "', "
sqlValues(6) = "'" & Session("department") & "', "
sqlValues(7) = "'" & Session("age") & "', "
sqlValues(8) = "'" & Session("grade") & "', "
sqlValues(9) = "'" & Request.Form("1") & "', "
sqlValues(10) = "'" & Request.Form("2") & "', "
sqlValues(11) = "'" & Request.Form("3") & "', "
sqlValues(12) = "'" & Request.Form("4") & "', "
sqlValues(13) = "'" & Request.Form("5") & "', "
...

sql = Join(sqlValues)

Is there any possible way I can avoid having to hard code
the above and have the page work out what it needs to do
dynamically?


try this:
http://www.aspfaq.com/show.asp?id=2036

--
Tom Kaminski IIS MVP
http://www.microsoft.com/windowsserv...y/centers/iis/
http://mvp.support.microsoft.com/
http://www.iisfaq.com/
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://www.tryiis.com
Jul 19 '05 #2
On Mon, 20 Sep 2004 06:40:24 -0700, "Colin Steadman"
<an*******@discussions.microsoft.com> wrote:
I've create a simple survey using ASP. Its finished and
works, but one aspect of my coding is annoying me and I
cant figure out a better way of doing it.
There's a lot of sample ASP code out there to do surveys, take a look
at some of the methodology. Survey responses are not the easiest
things to code when you allow multiple types of questions, you may
find a canned package is cheap compared to your time.

Jeff

Basically the questions are stored in an Access 2000 table
like this:

QUESTION_NUMBER QUESTION
1 Question 1 text....
2 Question 2 text....
3 Question 3 text....
4 Question 4 text....
5 Question 5 text....

My ASP page gets these questions and displays them in a
form dynamically. The user then answers the questions by
clicking radio buttons (Agree, Tend to agree, Not sure...
ect).

This works well and if I want to add a question I just
update the database table.

The problem is I've not been able to figure out how to
make the submit page dynamic. I'm having to manually add
code to my submit page to look after each question
individually rather than looping through the Form
collection.

For example when I build the SQL to update the database I
have to do it like this (note the last five lines look
after the responses to my five questions):

ReDim sqlValues(40)

sqlValues(0) = "values ("
sqlValues(1) = "'" & Session("emp_no") & "', "
sqlValues(2) = "'" & Session("Username") & "', "
sqlValues(3) = "'" & Session("sex") & "', "
sqlValues(4) = "'" & Session("phone") & "', "
sqlValues(5) = "'" & Session("job_title") & "', "
sqlValues(6) = "'" & Session("department") & "', "
sqlValues(7) = "'" & Session("age") & "', "
sqlValues(8) = "'" & Session("grade") & "', "
sqlValues(9) = "'" & Request.Form("1") & "', "
sqlValues(10) = "'" & Request.Form("2") & "', "
sqlValues(11) = "'" & Request.Form("3") & "', "
sqlValues(12) = "'" & Request.Form("4") & "', "
sqlValues(13) = "'" & Request.Form("5") & "', "
...

sql = Join(sqlValues)

Is there any possible way I can avoid having to hard code
the above and have the page work out what it needs to do
dynamically?

TIA,

Colin


Jul 19 '05 #3
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message news:<ci**********@kcweb01.netnews.att.com>...

try this:
http://www.aspfaq.com/show.asp?id=2036


Hummm... thanks Tom, I think I can use the ideas in that example.

Cheers,

Colin
Jul 19 '05 #4
je*********@zina.com (Jeff Cochran) wrote in message news:<41****************@msnews.microsoft.com>...

There's a lot of sample ASP code out there to do surveys, take a look
at some of the methodology.
I did try looking for some examples, but this project came from
no-where without warning and I was only given a day to sort it out. I
literally had to scrawl some ideas on a bit of paper and got cracking.
It was great fun though.

Survey responses are not the easiest
things to code when you allow multiple types of questions, you may
find a canned package is cheap compared to your time.

Jeff


I was fortunate that all the questions were to be answered in the same
way. If it has been a jumble of question types I wouldn't have had a
chance.

Colin
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: GTF | last post by:
PHP Web Survey Idea.. I have been given an opportunity to create a web based survey. This is a fairly lengthy survey of 60 pages on paper (various multiple choice and free form). These are...
5
by: Dan | last post by:
Hi, I want to migrate a survey program to web application and have selected PHP to use a on the server end along with apache and firebird rdms. As developing a web application is much different...
5
by: DFS | last post by:
I've written several survey systems in which the majority of the questions have the same or similar responses (Yes/No, True/False, scale of 1 - 5, etc). But this latest survey system I'm working...
27
by: elena | last post by:
I'm a Java/C++ developer who is also studying psychology. I would really appreciate it if you would complete a survey that I'm using for a research project on programmers. It's easy and takes...
0
by: Henry | last post by:
Hi Everyone, My name is Henry and I'm a Master of Computing student at Unitec New Zealand (www.unitec.ac.nz). I'm currently doing my Thesis titled: "Utilizing Newsgroups as Customer Support Tool...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
0
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event,...
5
by: shaffer | last post by:
Yea im trying to make a christmas survey program for my class project, Im using strings to set 20 variables, Not a experienced programmer this is my first year in classes just trying to learn and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.