Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old February 28th, 2006, 01:55 PM
raj chahal
Guest
 
Posts: n/a
Default checkboxes and databases

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


  #2  
Old February 28th, 2006, 02:25 PM
Paxton
Guest
 
Posts: n/a
Default Re: checkboxes and databases


raj chahal wrote:[color=blue]
> 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[/color]

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.

  #3  
Old February 28th, 2006, 02:25 PM
Phillip Windell
Guest
 
Posts: n/a
Default Re: checkboxes and databases


"raj chahal" <info@digitise.info> wrote in message
news:%23uo8LwGPGHA.3576@TK2MSFTNGP15.phx.gbl...[color=blue]
> 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[/color]
in[color=blue]
> the database ?[/color]

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/IS...cessRules.html

Troubleshooting Client Authentication on Access Rules in ISA Server 2004
http://download.microsoft.com/downlo...7/ts_rules.doc

Microsoft Internet Security & Acceleration Server: Guidance
http://www.microsoft.com/isaserver/t...dance/2004.asp
http://www.microsoft.com/isaserver/t...dance/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/pro...isaserver.mspx
-----------------------------------------------------



 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.