More form processing

Ask a Question related to ASP, Design and Development.

  1. #1

    Default More form processing

    Hey folks,

    I need some of your expertiese again. I am creating a survey form and need
    some help gathering the results of a question that has checkboxes. There
    are four options for one of the questions for example

    Where do you normally buy books?
    o Bookstore
    o Online
    o Book club
    o Other

    I'm going to store the answers in a DB and I dont want to have have four
    fields if only two of them are going to get used. Im trying to find a GOOD
    way to collect the results perhaps in an array or comma seperated list so I
    could store it in onefield.

    Right now here is what I have

    <%
    strBuyBook1 = Trim(Request.Form("buy_book1"))
    strBuyBook2 = Trim(Request.Form("buy_book2"))
    strBuyBook3 = Trim(Request.Form("buy_book3"))
    strBuyBook4 = Trim(Request.Form("buy_book4"))

    Connect to the database
    call OpenDB()

    SQL = "INSERT INTO tblAnswers( BuyBook1, BuyBook2, BuyBook3, BuyBook4)" & _
    "VALUES ('" & strBuyBook1 & "', '" & strBuyBook2 & "', '" &
    strBuyBook3 & "', '" & strBuyBook4 & "')"

    con.Execute SQL

    %>


    Thanks in anticipation
    Simon


    Simon Guest

  2. Similar Questions and Discussions

    1. DW MX - Extension for Form Processing?
      Hello, I'm back on DW MX after a break from it. And in a way, I'm addressing here the crux of why I had to go back to Frontpage for a while. In...
    2. Form Processing Applications
      I have not had much experience with forms processing, but need to build one for a site. I saw a link to Kmita-mail (http://www1.kmita-mail.com/)...
    3. Secure Form processing
      After a user clicks the submit button on an order form, I am unable to get the redirect specified in the form to go to a secure page. This causes...
    4. Html form processing
      I have been trying this for a few days now. I seem to get parts of it, but I can't get the full scenario to work. I have a page that has an email...
    5. Form Processing
      Hi, I am designing a basic email form using Dreamweaver and the checks are successful. Does Dreamweaver have any functionality to enable me to...
  3. #2

    Default Re: More form processing

    I would create a second table with a list of every item that is
    available and associate the text string with a unique key. Then place
    the unique key in the users record seperated by commas.

    hth,
    Andrew

    * * * Sent via DevBuilder [url]http://www.devbuilder.org[/url] * * *
    Developer Resources for High End Developers.
    Andrew Durstewitz Guest

  4. #3

    Default Re: More form processing

    Nah, you're still thinking in spreadsheet terms. There are good reasons for
    database normalization.
    Simon wrote:
    > I agree I dont really want to store multiple values in a single
    > field, I would like to have two fields in my database. I was
    > thinking along the lines using the split function to create an array
    > and inserting each array item into its own field. To do that I would
    > have to prevent teh user form checking more than two checkboxes but
    > Im not sure how to do that either :-\
    >
    >
    > "Bob Barrows" <reb_01501@yahoo.com> wrote in message
    > news:OICsO%23%23PDHA.3880@tk2msftngp13.phx.gbl...
    >> <rant>
    >> It is a bad idea to store multiple data values in a single field.
    >> This is a database, not a spreadsheet. Someday you are going to need
    >> to look at these values individually: think of the hell you are
    >> going to go through to separate them out. Say you want to know what
    >> percentage of people use a bookstore?
    >> </rant>
    >>
    >> You should use a separate table called BookSources with two columns:
    >> ResponseID and BookSource. ResponseID ties a booksource record back
    >> to a response record. There will be a 1 to many relationship between
    >> Responses and BookSources.
    >>
    >> If you give all four checkboxes the same name:
    >> <INPUT type="checkbox" name="buy_book" value="Bookstore">
    >> <INPUT type="checkbox" name="buy_book" value="Online">
    >> etc.
    >> , you can process the inputs as a collection:
    >>
    >> 'You will need to have assigned a ResponseID prior to this step
    >> for each vData in request.form("buy_book")
    >> SQL = "insert into BookSources Values (" & ResponseID & _
    >> ", '" & vData & "')"
    >> con.Execute SQL
    >> next
    >>
    >> HTH,
    >> Bob Barrows
    >>
    >> Simon wrote:
    >>> Hey folks,
    >>>
    >>> I need some of your expertiese again. I am creating a survey form
    >>> and need some help gathering the results of a question that has
    >>> checkboxes. There are four options for one of the questions for
    >>> example
    >>>
    >>> Where do you normally buy books?
    >>> o Bookstore
    >>> o Online
    >>> o Book club
    >>> o Other
    >>>
    >>> I'm going to store the answers in a DB and I dont want to have have
    >>> four fields if only two of them are going to get used. Im trying to
    >>> find a GOOD way to collect the results perhaps in an array or comma
    >>> seperated list so I could store it in onefield.
    >>>
    >>> Right now here is what I have
    >>>
    >>> <%
    >>> strBuyBook1 = Trim(Request.Form("buy_book1"))
    >>> strBuyBook2 = Trim(Request.Form("buy_book2"))
    >>> strBuyBook3 = Trim(Request.Form("buy_book3"))
    >>> strBuyBook4 = Trim(Request.Form("buy_book4"))
    >>>
    >>> Connect to the database
    >>> call OpenDB()
    >>>
    >>> SQL = "INSERT INTO tblAnswers( BuyBook1, BuyBook2, BuyBook3,
    >>> BuyBook4)" & _ "VALUES ('" & strBuyBook1 & "', '" &
    >>> strBuyBook2 & "', '" &
    >>> strBuyBook3 & "', '" & strBuyBook4 & "')"
    >>>
    >>> con.Execute SQL
    >>>
    >>> %>
    >>>
    >>>
    >>> Thanks in anticipation
    >>> Simon

    Bob Barrows Guest

  5. #4

    Default Re: More form processing

    Im trying really hard not to! Im not pulling any of my questions/options
    from a database I just want to save the results in a database.

    Could I email you my code?

    Thanks again
    Simon


    "Bob Barrows" <reb_01501@yahoo.com> wrote in message
    news:ehAwkZ$PDHA.2476@TK2MSFTNGP10.phx.gbl...
    > Nah, you're still thinking in spreadsheet terms. There are good reasons
    for
    > database normalization.
    > Simon wrote:
    > > I agree I dont really want to store multiple values in a single
    > > field, I would like to have two fields in my database. I was
    > > thinking along the lines using the split function to create an array
    > > and inserting each array item into its own field. To do that I would
    > > have to prevent teh user form checking more than two checkboxes but
    > > Im not sure how to do that either :-\
    > >
    > >
    > > "Bob Barrows" <reb_01501@yahoo.com> wrote in message
    > > news:OICsO%23%23PDHA.3880@tk2msftngp13.phx.gbl...
    > >> <rant>
    > >> It is a bad idea to store multiple data values in a single field.
    > >> This is a database, not a spreadsheet. Someday you are going to need
    > >> to look at these values individually: think of the hell you are
    > >> going to go through to separate them out. Say you want to know what
    > >> percentage of people use a bookstore?
    > >> </rant>
    > >>
    > >> You should use a separate table called BookSources with two columns:
    > >> ResponseID and BookSource. ResponseID ties a booksource record back
    > >> to a response record. There will be a 1 to many relationship between
    > >> Responses and BookSources.
    > >>
    > >> If you give all four checkboxes the same name:
    > >> <INPUT type="checkbox" name="buy_book" value="Bookstore">
    > >> <INPUT type="checkbox" name="buy_book" value="Online">
    > >> etc.
    > >> , you can process the inputs as a collection:
    > >>
    > >> 'You will need to have assigned a ResponseID prior to this step
    > >> for each vData in request.form("buy_book")
    > >> SQL = "insert into BookSources Values (" & ResponseID & _
    > >> ", '" & vData & "')"
    > >> con.Execute SQL
    > >> next
    > >>
    > >> HTH,
    > >> Bob Barrows
    > >>
    > >> Simon wrote:
    > >>> Hey folks,
    > >>>
    > >>> I need some of your expertiese again. I am creating a survey form
    > >>> and need some help gathering the results of a question that has
    > >>> checkboxes. There are four options for one of the questions for
    > >>> example
    > >>>
    > >>> Where do you normally buy books?
    > >>> o Bookstore
    > >>> o Online
    > >>> o Book club
    > >>> o Other
    > >>>
    > >>> I'm going to store the answers in a DB and I dont want to have have
    > >>> four fields if only two of them are going to get used. Im trying to
    > >>> find a GOOD way to collect the results perhaps in an array or comma
    > >>> seperated list so I could store it in onefield.
    > >>>
    > >>> Right now here is what I have
    > >>>
    > >>> <%
    > >>> strBuyBook1 = Trim(Request.Form("buy_book1"))
    > >>> strBuyBook2 = Trim(Request.Form("buy_book2"))
    > >>> strBuyBook3 = Trim(Request.Form("buy_book3"))
    > >>> strBuyBook4 = Trim(Request.Form("buy_book4"))
    > >>>
    > >>> Connect to the database
    > >>> call OpenDB()
    > >>>
    > >>> SQL = "INSERT INTO tblAnswers( BuyBook1, BuyBook2, BuyBook3,
    > >>> BuyBook4)" & _ "VALUES ('" & strBuyBook1 & "', '" &
    > >>> strBuyBook2 & "', '" &
    > >>> strBuyBook3 & "', '" & strBuyBook4 & "')"
    > >>>
    > >>> con.Execute SQL
    > >>>
    > >>> %>
    > >>>
    > >>>
    > >>> Thanks in anticipation
    > >>> Simon
    >
    >

    Simon Guest

  6. #5

    Default Re: More form processing

    I've already given you a solution. Please read it again and try to
    understand it:
    Simon wrote:
    >>>>
    >>>> You should use a separate table called BookSources with two
    >>>> columns: ResponseID and BookSource. ResponseID ties a booksource
    >>>> record back to a response record. There will be a 1 to many
    >>>> relationship between Responses and BookSources.
    >>>>
    >>>> If you give all four checkboxes the same name:
    >>>> <INPUT type="checkbox" name="buy_book" value="Bookstore">
    >>>> <INPUT type="checkbox" name="buy_book" value="Online">
    >>>> etc.
    >>>> , you can process the inputs as a collection:
    >>>>
    >>>> 'You will need to have assigned a ResponseID prior to this step
    >>>> for each vData in request.form("buy_book")
    >>>> SQL = "insert into BookSources Values (" & ResponseID & _
    >>>> ", '" & vData & "')"
    >>>> con.Execute SQL
    >>>> next
    >>>>

    Bob Barrows Guest

  7. #6

    Default Re: More form processing

    If you want to follow more of a standard like Bob mentioned then here is
    a good article...

    [url]http://www.devbuilder.org/asp/dev_article.asp?aspid=13[/url]

    Bob, the question sounded more to me like he wanted a simple, quick
    solution. That was my answere. Putting multiple returns in the same
    feild isn't the best idea but you can break those out into a nice
    multi-dimensional array for fast processing.

    Whereas, if you had to go loop through a recordset it would take you
    longer.
    </rant> :oP

    Andrew

    * * * Sent via DevBuilder [url]http://www.devbuilder.org[/url] * * *
    Developer Resources for High End Developers.
    Andrew Durstewitz Guest

  8. #7

    Default Re: More form processing

    Bob,

    I have been thinking about what you said here but being somewhat of a novice
    when it comes to DB's Im having a hard time putting it together, I have
    searched all over (ok so thats probably an exageration) the web looking for
    examples on storing checkbox results in a datbase but to no avail.

    Do you think you could find it in your heart to provide me with an example?
    I know you have always been helpfull to me in the past.

    Thanks again
    Simon
    "Bob Barrows" <reb_01501@yahoo.com> wrote in message
    news:OICsO%23%23PDHA.3880@tk2msftngp13.phx.gbl...
    > <rant>
    > It is a bad idea to store multiple data values in a single field. This is
    a
    > database, not a spreadsheet. Someday you are going to need to look at
    these
    > values individually: think of the hell you are going to go through to
    > separate them out. Say you want to know what percentage of people use a
    > bookstore?
    > </rant>
    >
    > You should use a separate table called BookSources with two columns:
    > ResponseID and BookSource. ResponseID ties a booksource record back to a
    > response record. There will be a 1 to many relationship between Responses
    > and BookSources.
    >
    > If you give all four checkboxes the same name:
    > <INPUT type="checkbox" name="buy_book" value="Bookstore">
    > <INPUT type="checkbox" name="buy_book" value="Online">
    > etc.
    > , you can process the inputs as a collection:
    >
    > 'You will need to have assigned a ResponseID prior to this step
    > for each vData in request.form("buy_book")
    > SQL = "insert into BookSources Values (" & ResponseID & _
    > ", '" & vData & "')"
    > con.Execute SQL
    > next
    >
    > HTH,
    > Bob Barrows
    >
    > Simon wrote:
    > > Hey folks,
    > >
    > > I need some of your expertiese again. I am creating a survey form
    > > and need some help gathering the results of a question that has
    > > checkboxes. There are four options for one of the questions for
    > > example
    > >
    > > Where do you normally buy books?
    > > o Bookstore
    > > o Online
    > > o Book club
    > > o Other
    > >
    > > I'm going to store the answers in a DB and I dont want to have have
    > > four fields if only two of them are going to get used. Im trying to
    > > find a GOOD way to collect the results perhaps in an array or comma
    > > seperated list so I could store it in onefield.
    > >
    > > Right now here is what I have
    > >
    > > <%
    > > strBuyBook1 = Trim(Request.Form("buy_book1"))
    > > strBuyBook2 = Trim(Request.Form("buy_book2"))
    > > strBuyBook3 = Trim(Request.Form("buy_book3"))
    > > strBuyBook4 = Trim(Request.Form("buy_book4"))
    > >
    > > Connect to the database
    > > call OpenDB()
    > >
    > > SQL = "INSERT INTO tblAnswers( BuyBook1, BuyBook2, BuyBook3,
    > > BuyBook4)" & _ "VALUES ('" & strBuyBook1 & "', '" &
    > > strBuyBook2 & "', '" &
    > > strBuyBook3 & "', '" & strBuyBook4 & "')"
    > >
    > > con.Execute SQL
    > >
    > > %>
    > >
    > >
    > > Thanks in anticipation
    > > Simon
    >
    >

    Simon Guest

  9. #8

    Default Re: Bob Barrows

    This will take a while. I am really busy today. Hopefully someone else will
    step in here. I'll check again later to see if you still need help.

    Bob

    Simon wrote:
    > Bob,
    >
    > I have been thinking about what you said here but being somewhat of a
    > novice when it comes to DB's Im having a hard time putting it
    > together, I have searched all over (ok so thats probably an
    > exageration) the web looking for examples on storing checkbox
    > results in a datbase but to no avail.
    >
    > Do you think you could find it in your heart to provide me with an
    > example? I know you have always been helpfull to me in the past.
    >
    > Thanks again
    > Simon
    > "Bob Barrows" <reb_01501@yahoo.com> wrote in message
    > news:OICsO%23%23PDHA.3880@tk2msftngp13.phx.gbl...
    >> <rant>
    >> It is a bad idea to store multiple data values in a single field.
    >> This is a database, not a spreadsheet. Someday you are going to need
    >> to look at these values individually: think of the hell you are
    >> going to go through to separate them out. Say you want to know what
    >> percentage of people use a bookstore?
    >> </rant>
    >>
    >> You should use a separate table called BookSources with two columns:
    >> ResponseID and BookSource. ResponseID ties a booksource record back
    >> to a response record. There will be a 1 to many relationship between
    >> Responses and BookSources.
    >>
    >> If you give all four checkboxes the same name:
    >> <INPUT type="checkbox" name="buy_book" value="Bookstore">
    >> <INPUT type="checkbox" name="buy_book" value="Online">
    >> etc.
    >> , you can process the inputs as a collection:
    >>
    >> 'You will need to have assigned a ResponseID prior to this step
    >> for each vData in request.form("buy_book")
    >> SQL = "insert into BookSources Values (" & ResponseID & _
    >> ", '" & vData & "')"
    >> con.Execute SQL
    >> next
    >>
    >> HTH,
    >> Bob Barrows
    >>
    >> Simon wrote:
    >>> Hey folks,
    >>>
    >>> I need some of your expertiese again. I am creating a survey form
    >>> and need some help gathering the results of a question that has
    >>> checkboxes. There are four options for one of the questions for
    >>> example
    >>>
    >>> Where do you normally buy books?
    >>> o Bookstore
    >>> o Online
    >>> o Book club
    >>> o Other
    >>>
    >>> I'm going to store the answers in a DB and I dont want to have have
    >>> four fields if only two of them are going to get used. Im trying to
    >>> find a GOOD way to collect the results perhaps in an array or comma
    >>> seperated list so I could store it in onefield.
    >>>
    >>> Right now here is what I have
    >>>
    >>> <%
    >>> strBuyBook1 = Trim(Request.Form("buy_book1"))
    >>> strBuyBook2 = Trim(Request.Form("buy_book2"))
    >>> strBuyBook3 = Trim(Request.Form("buy_book3"))
    >>> strBuyBook4 = Trim(Request.Form("buy_book4"))
    >>>
    >>> Connect to the database
    >>> call OpenDB()
    >>>
    >>> SQL = "INSERT INTO tblAnswers( BuyBook1, BuyBook2, BuyBook3,
    >>> BuyBook4)" & _ "VALUES ('" & strBuyBook1 & "', '" &
    >>> strBuyBook2 & "', '" &
    >>> strBuyBook3 & "', '" & strBuyBook4 & "')"
    >>>
    >>> con.Execute SQL
    >>>
    >>> %>
    >>>
    >>>
    >>> Thanks in anticipation
    >>> Simon


    Bob Barrows Guest

  10. #9

    Default Re: Bob Barrows

    dont supose youhave had a chance to look at this Bob?

    Sorry to be a pain.

    simon
    "Bob Barrows" <reb_01501@yahoo.com> wrote in message
    news:exynUg4SDHA.2020@TK2MSFTNGP11.phx.gbl...
    > This will take a while. I am really busy today. Hopefully someone else
    will
    > step in here. I'll check again later to see if you still need help.
    >
    > Bob
    >
    > Simon wrote:
    > > Bob,
    > >
    > > I have been thinking about what you said here but being somewhat of a
    > > novice when it comes to DB's Im having a hard time putting it
    > > together, I have searched all over (ok so thats probably an
    > > exageration) the web looking for examples on storing checkbox
    > > results in a datbase but to no avail.
    > >
    > > Do you think you could find it in your heart to provide me with an
    > > example? I know you have always been helpfull to me in the past.
    > >
    > > Thanks again
    > > Simon
    > > "Bob Barrows" <reb_01501@yahoo.com> wrote in message
    > > news:OICsO%23%23PDHA.3880@tk2msftngp13.phx.gbl...
    > >> <rant>
    > >> It is a bad idea to store multiple data values in a single field.
    > >> This is a database, not a spreadsheet. Someday you are going to need
    > >> to look at these values individually: think of the hell you are
    > >> going to go through to separate them out. Say you want to know what
    > >> percentage of people use a bookstore?
    > >> </rant>
    > >>
    > >> You should use a separate table called BookSources with two columns:
    > >> ResponseID and BookSource. ResponseID ties a booksource record back
    > >> to a response record. There will be a 1 to many relationship between
    > >> Responses and BookSources.
    > >>
    > >> If you give all four checkboxes the same name:
    > >> <INPUT type="checkbox" name="buy_book" value="Bookstore">
    > >> <INPUT type="checkbox" name="buy_book" value="Online">
    > >> etc.
    > >> , you can process the inputs as a collection:
    > >>
    > >> 'You will need to have assigned a ResponseID prior to this step
    > >> for each vData in request.form("buy_book")
    > >> SQL = "insert into BookSources Values (" & ResponseID & _
    > >> ", '" & vData & "')"
    > >> con.Execute SQL
    > >> next
    > >>
    > >> HTH,
    > >> Bob Barrows
    > >>
    > >> Simon wrote:
    > >>> Hey folks,
    > >>>
    > >>> I need some of your expertiese again. I am creating a survey form
    > >>> and need some help gathering the results of a question that has
    > >>> checkboxes. There are four options for one of the questions for
    > >>> example
    > >>>
    > >>> Where do you normally buy books?
    > >>> o Bookstore
    > >>> o Online
    > >>> o Book club
    > >>> o Other
    > >>>
    > >>> I'm going to store the answers in a DB and I dont want to have have
    > >>> four fields if only two of them are going to get used. Im trying to
    > >>> find a GOOD way to collect the results perhaps in an array or comma
    > >>> seperated list so I could store it in onefield.
    > >>>
    > >>> Right now here is what I have
    > >>>
    > >>> <%
    > >>> strBuyBook1 = Trim(Request.Form("buy_book1"))
    > >>> strBuyBook2 = Trim(Request.Form("buy_book2"))
    > >>> strBuyBook3 = Trim(Request.Form("buy_book3"))
    > >>> strBuyBook4 = Trim(Request.Form("buy_book4"))
    > >>>
    > >>> Connect to the database
    > >>> call OpenDB()
    > >>>
    > >>> SQL = "INSERT INTO tblAnswers( BuyBook1, BuyBook2, BuyBook3,
    > >>> BuyBook4)" & _ "VALUES ('" & strBuyBook1 & "', '" &
    > >>> strBuyBook2 & "', '" &
    > >>> strBuyBook3 & "', '" & strBuyBook4 & "')"
    > >>>
    > >>> con.Execute SQL
    > >>>
    > >>> %>
    > >>>
    > >>>
    > >>> Thanks in anticipation
    > >>> Simon
    >
    >
    >

    Simon Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139