checkboxes and databases

R

raj chahal

hi there

I want to collect user input. I have a collection of 30 checkboxes that I
would like the user to pickout from. The information then will be recorded
to a database somehow. Finally the user will be allowed to change the
selection if required.

Which is the best way to do this. Do I need to create 30 different fields in
the database ?

Thanks
 
P

Paxton

raj said:
hi there

I want to collect user input. I have a collection of 30 checkboxes that I
would like the user to pickout from. The information then will be recorded
to a database somehow. Finally the user will be allowed to change the
selection if required.

Which is the best way to do this. Do I need to create 30 different fields in
the database ?

Thanks

3 tables - one to hold user information, one to hold checkbox
information and one to join the two. So, if your checkboxes related to
colours, for example, the checkbox information table would be called
Colours. It would have an ColourID field and a ColourName field. To
write the checkboxes to the browser, you would select the records:

<%
sql="SELECT ColourID, ColourName FROM Colours"
set rs = conn.execute(sql)
if not rs.eof then
arrColours = rs.getrows
rs.close : set rs = nothing
for i = 0 to ubound(arrColours,2)
response.write "<input type='checkbox' name='colourid' value='"
& arrColours(0,i) & "'>"
response.write arrColours(1,i) & "<br>" & vbcrlf
next
else
response.write "no records"
rs.close : set rs = nothing
end if
%>

Once a user has made their selection, and you have caught their userid
in the form somewhere ( or querystring), on submission,
Request.Form("colourid") will hold a comma-delimited string of values.
This is where the 3rd table - UserColours comes into play. It has 2
fields - UserID and ColourID.

To process the comma-delimited string, do something like this:

<%
colours = Request.Form("ColourID")
colours = split(colours,",")
for i = 0 to ubound(colours)
conn.execute("Insert INTO UserColours (UserID, ColourID) VALUES ("
& userid & "," & colours(i) & ")")
next
%>

/P.
 
P

Phillip Windell

raj chahal said:
I want to collect user input. I have a collection of 30 checkboxes that I
would like the user to pickout from. The information then will be recorded
to a database somehow. Finally the user will be allowed to change the
selection if required.

Which is the best way to do this. Do I need to create 30 different fields in
the database ?

That depends on what the check boxes are. It would most likely be one field
for each "group" of checkboxes.

--
Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com
-----------------------------------------------------
Understanding the ISA 2004 Access Rule Processing
http://www.isaserver.org/articles/ISA2004_AccessRules.html

Troubleshooting Client Authentication on Access Rules in ISA Server 2004
http://download.microsoft.com/download/9/1/8/918ed2d3-71d0-40ed-8e6d-fd6eeb6cfa07/ts_rules.doc

Microsoft Internet Security & Acceleration Server: Guidance
http://www.microsoft.com/isaserver/techinfo/Guidance/2004.asp
http://www.microsoft.com/isaserver/techinfo/Guidance/2000.asp

Microsoft Internet Security & Acceleration Server: Partners
http://www.microsoft.com/isaserver/partners/default.asp

Deployment Guidelines for ISA Server 2004 Enterprise Edition
http://www.microsoft.com/technet/prodtechnol/isa/2004/deploy/dgisaserver.mspx
-----------------------------------------------------
 

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
474,144
Messages
2,570,823
Members
47,369
Latest member
FTMZ

Latest Threads

Top