|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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? |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
right - makes sense.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Radio Buttons and CheckBoxes - Adding and Retrieving Info |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|