Voting on an ASP page

Discussion in 'ASP General' started by Richard Speiss, Nov 11, 2005.

  1. 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
     
    Richard Speiss, Nov 11, 2005
    #1
    1. Advertising

  2. Richard Speiss

    Larry Bud Guest

    > 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
     
    Larry Bud, Nov 14, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr Bean

    Internet radio and voting...

    Mr Bean, Jun 27, 2005, in forum: HTML
    Replies:
    1
    Views:
    391
    Travis Newbury
    Jun 27, 2005
  2. Alan Dechert
    Replies:
    29
    Views:
    1,055
  3. Alan Dechert

    Python voting demo discussion

    Alan Dechert, Jul 21, 2003, in forum: Python
    Replies:
    9
    Views:
    412
    Andrew Dalke
    Jul 21, 2003
  4. Alan Dechert

    Voting Project Needs Python People

    Alan Dechert, Jul 21, 2003, in forum: Python
    Replies:
    23
    Views:
    715
    Andrew Dalke
    Aug 2, 2003
  5. dw

    Margin of error on ASP voting app

    dw, Aug 10, 2005, in forum: ASP General
    Replies:
    3
    Views:
    116
Loading...

Share This Page