Voting on an ASP page

R

Richard Speiss

I am learning ASP and have my website working pretty well. Now I want to
add a "Surveys" section to it. The format will be something like:

Question 1
Choice 1
Choice 2

Vote
------------
Question 2
Choice 1
Choice 2

Vote

The page will contain more questions as time goes on. Each question and the
choices will come from a database. Each question and each choice has a
unique ID. Each choice will be a radio button

When the user presses the Vote button it needs to pass:
- The ID of the Question
- The ID of the Choice

The update.asp will expect to see the question ID, the choice ID and will
update the database based on that information.

I'm not sure how to go about passing the IDs since they will not be visible
on the webpage.

Am I going about this the right way? Is there a better way?

Any thoughts to point me in the right direction will be most welcome

Richard Speiss
 
L

Larry Bud

The page will contain more questions as time goes on. Each question and the
choices will come from a database. Each question and each choice has a
unique ID. Each choice will be a radio button

When the user presses the Vote button it needs to pass:
- The ID of the Question
- The ID of the Choice

The update.asp will expect to see the question ID, the choice ID and will
update the database based on that information.

I'm not sure how to go about passing the IDs since they will not be visible
on the webpage.

Am I going about this the right way? Is there a better way?

If you're going to use radio buttons for your voting, you won't have to
pass an ID of the choice. You're going to be passing the choice as the
value of the question.

I.e. Lets say your question ID is 15, and you have 3 choices for the
voting. The HTML would be

First Choice<input type="radio" value="1" name="q_15"><BR>
Second Choice<input type="radio" value="2" name="q_15"><BR>
Third Choice<input type="radio" value="3" name="q_15">

Note that the name of each control is the same, because they are part
of the same group. You will dynamically create the name based on the
ID.

When the form is submitted, you need to iterate through the form since
you don't know waht question IDs to retrieve.. i.e.

for each element in request.form
if left(request.form(element),2)="q_" then
'this is a valid question, process the result here
end if
next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top