HTML Forms - Other Input Types
(Page 2 of 6 )
Radio buttons are used when you want the user to choose from a limited number of choices. They are named from old style radio buttons that you press in. Here is a sample of how they look in code:
<html>
<body>
<form action="">
<p>Are You Fat?</p>
Yes:
<input type="radio" checked="checked"
name="Fat" value="yes">
<br>
No:
<input type="radio"
name="Fat" value="no">
</form>
</body>
</html>
This would display:
Are You Fat?
Note that the type is "radio" and that the "Yes" radio button's checked value is "checked." This means that in the list of buttons, the "Yes" button is checked by default. If the user clicks on the "No" button, the "Yes" becomes unchecked.
You may also notice that both buttons share the same name. If the buttons are to work together, the name value must be the same. Otherwise when you click on one, then another, they will both remain checked.
Next: Checkboxes >>
More HTML Articles
More By James Payne