More form processing

S

Simon

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
 
A

Andrew Durstewitz

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 http://www.devbuilder.org * * *
Developer Resources for High End Developers.
 
B

Bob Barrows

Nah, you're still thinking in spreadsheet terms. There are good reasons for
database normalization.
 
S

Simon

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
 
B

Bob Barrows

I've already given you a solution. Please read it again and try to
understand it:
 
A

Andrew Durstewitz

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

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

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> :eek:P

Andrew

* * * Sent via DevBuilder http://www.devbuilder.org * * *
Developer Resources for High End Developers.
 
S

Simon

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
 
B

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top