473,698 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Fo rm("buy_book1") )
strBuyBook2 = Trim(Request.Fo rm("buy_book2") )
strBuyBook3 = Trim(Request.Fo rm("buy_book3") )
strBuyBook4 = Trim(Request.Fo rm("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
Jul 19 '05 #1
8 2469
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.
Jul 19 '05 #2
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" <re*******@yaho o.com> wrote in message
news:OI******** **********@tk2m sftngp13.phx.gb l...
<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="Bookstor e">
<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("b uy_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.Fo rm("buy_book1") )
strBuyBook2 = Trim(Request.Fo rm("buy_book2") )
strBuyBook3 = Trim(Request.Fo rm("buy_book3") )
strBuyBook4 = Trim(Request.Fo rm("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

Jul 19 '05 #3
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" <re*******@yaho o.com> wrote in message
news:eh******** ******@TK2MSFTN GP10.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" <re*******@yaho o.com> wrote in message
news:OI******** **********@tk2m sftngp13.phx.gb l...
<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="Bookstor e">
<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("b uy_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.Fo rm("buy_book1") )
strBuyBook2 = Trim(Request.Fo rm("buy_book2") )
strBuyBook3 = Trim(Request.Fo rm("buy_book3") )
strBuyBook4 = Trim(Request.Fo rm("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


Jul 19 '05 #4
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="Bookstor e">
<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("b uy_book")
SQL = "insert into BookSources Values (" & ResponseID & _
", '" & vData & "')"
con.Execute SQL
next

Jul 19 '05 #5
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> :oP

Andrew

* * * Sent via DevBuilder http://www.devbuilder.org * * *
Developer Resources for High End Developers.
Jul 19 '05 #6
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" <re*******@yaho o.com> wrote in message
news:OI******** **********@tk2m sftngp13.phx.gb l...
<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="Bookstor e">
<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("b uy_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.Fo rm("buy_book1") )
strBuyBook2 = Trim(Request.Fo rm("buy_book2") )
strBuyBook3 = Trim(Request.Fo rm("buy_book3") )
strBuyBook4 = Trim(Request.Fo rm("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


Jul 19 '05 #7
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" <re*******@yaho o.com> wrote in message
news:OI******** **********@tk2m sftngp13.phx.gb l...
<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="Bookstor e">
<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("b uy_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.Fo rm("buy_book1") )
strBuyBook2 = Trim(Request.Fo rm("buy_book2") )
strBuyBook3 = Trim(Request.Fo rm("buy_book3") )
strBuyBook4 = Trim(Request.Fo rm("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


Jul 19 '05 #8
dont supose youhave had a chance to look at this Bob?

Sorry to be a pain.

simon
"Bob Barrows" <re*******@yaho o.com> wrote in message
news:ex******** ******@TK2MSFTN GP11.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" <re*******@yaho o.com> wrote in message
news:OI******** **********@tk2m sftngp13.phx.gb l...
<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="Bookstor e">
<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("b uy_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.Fo rm("buy_book1") )
strBuyBook2 = Trim(Request.Fo rm("buy_book2") )
strBuyBook3 = Trim(Request.Fo rm("buy_book3") )
strBuyBook4 = Trim(Request.Fo rm("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


Jul 19 '05 #9

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

Similar topics

1
3137
by: Danny Anderson | last post by:
Hola, PHP folk! I have a php page that contains a self-processing form. The form holds search results. The search terms originally came from the previous page, but the user can repeatedly refine the results on the page in question until the target item can be found. This search refinement is where the self-processing form comes to play. The search results are listed in a table with a radio button at the end of each row. What I...
303
17632
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
1
5072
by: David Bradbury | last post by:
Hi On my form, as soon as the user clicks my submit button a message pops up saying "Form processing" as the form submits. This is fine as long as the user only clicks the submit button once. However, if I try and stop the user submitting a second time (if they click the button for a second time despite the form processing message) by using a submission counter then my form just hangs forever with the "Form processing" message. Any...
8
3276
by: Raed Sawalha | last post by:
I have form with progress bar ,when application begin processing and progress bar moving if I minimized the form and try to restore it ,it is not showing until the processing completed ,how can I enabled minimize, maximize moving form while processing in underway?
8
26788
by: Brian Fulford | last post by:
This is my first shot at a Winforms application in dot net. This application is mainly going to run unattended but is using a form to display current activity of the background processing. In VB6, I could set the startup to be Sub Main and then call frmMain.Show and the program would continue processing; however, after instantiating the from in VB.Net - dim frmMain as new frmMain, frmMain.show shows the form then closes the form to continue...
2
3710
by: AJang | last post by:
My windows form "Form1" has one Button "button1" and one TextBox "textBox1". When I click button1, it do a job for each file in a directory. The job include some platform invoke call. Before processing a file, I set textBox1's Text property as filename of the file processed, and call this->refresh() to refresh the form. Every thing seems OK. But, if the process time for some file is a little long (say 10 seconds) and during processing...
2
5771
by: rdemyan via AccessMonster.com | last post by:
My application has a lot of complicated SQL statements, calculations, processing that takes time. I've created a custom form to act like a messagebox. It has 10 small rectangles on it that change color sequentially to let the user know that processing is occurring. This 'animation' occurs via the form timer event. However, I'm having trouble getting the animation to occur for all types of processing events. It appears that I have to...
9
2194
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but that has problems. FullName=Request.Form("Name") Email=Request.Form("Email") GivenName=Request.Form("GivenName")
6
1721
by: pippapippa | last post by:
I should be most grateful for a little advice. I have used Access 2000 & latterly 2002. Am about to upgrade since it is evident that documentation, tutorials etc are more readily available in later versions. I work on this on my lonesome & do not have access to a mentor or tuition. This is an intermittent activity and quite adjunct to my "normal" investment activities. I have found that most books & documentation are either...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8856
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4613
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.