The distinction between a radio and a check box
Before we officially jump in, its important to first make sure that everyone's clear on the distinction between a radio and a check box.
|What's your gender?||What are your hobbies?|
Only one radio box in a group can be selected at a time, whereas with check boxes, multiple selections are allowed. I hope no one finds the need to use checkboxes for the first question!
<form name="example"> <input type="radio" name="test"> </form> <script> //accesses the button called "test" document.example.test </script>
Changing the state of a box
|checked||Contains a boolean value indicating whether a box is selected or not. Writable.|
Using this property, we can not only determine the state of a box, but change it as well, by assigning either a value of "true" or "false" to it.
//alerts whether a box is checked alert(document.example.test.checked) //Dynamically selects a box document.example.test.checked=true
Now that we know how to access and manipulate a single box, lets expand our workarea to cover an entire group of boxes.
- Tutorial introduction
- Grouping multiple boxes together
- Techniques for determining which box is selected in a group