ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 6th, 2002, 03:49 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
Radio Buttons and CheckBoxes - Adding and Retrieving Info

Can anyone tell me the best practice for adding info from checkboxes and radio buttons to a database via asp as well as how to retrieve that information to show that the radio button/checkbox has been selected.

For checkboxes, should I use Bit as the datatype on SQL server? If so, is selected = 0?

Should I be adding to the database the fact that the item was not selected too? unselected = 1?

Also, can you dynamically generate a list of checkboxes and radio buttons?

Thanks a lot!

Last edited by aspnewbie : December 6th, 2002 at 03:58 PM.

Reply With Quote
  #2  
Old December 7th, 2002, 01:40 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
When talking computers - On/True = 1 and Off/False = 0. So, a checked checkbox would equal True (1). You were right about the datatype - use Bit

So, when you want to load the info from the DB, and want to show whether the box is checked or not, you'd do something like this.

if DBCheckboxvalue = true then
response.write("<input type=checkbox otherstuff... checked>")
end if

essentially, you add the CHECKED attribute for checked boxs.

Yes, you can dynamically generate checkboxs/radio buttons... there's a million ways to do this... depends on how u want to go about it.

Reply With Quote
  #3  
Old December 8th, 2002, 06:15 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
so the value of the checkbox, when adding it to the database, would be "true"?

i.e.,

<input type=checkbox value=true name=sNewsletter>

same for radio buttons?

Reply With Quote
  #4  
Old December 8th, 2002, 06:34 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Correct - for checkboxes, because they are either on or off.

Cept with radio buttons - you normally want to store a particular value... e.g. a poll on people's opinion of something, you'd store either, Good, Best, Bad, Worst... something like that.

Reply With Quote
  #5  
Old December 8th, 2002, 06:43 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
right - makes sense.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Radio Buttons and CheckBoxes - Adding and Retrieving Info


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT