weballey logo
 
left forms - radio button backnext right
homesearchsite mape-mail
intro
text
textarea
buttons
image
form
e-mail form
checkbox
< radio >
select
password
hidden
layout
cgi
tags
epilogue
      Sometimes you will want to choose only one option out of a list. Like the list on the checkbox page, with the question "What is your favorite color?". Clearly you will have only one favorite color, unless you can never make up your mind about anything.

<INPUT TYPE="radio" NAME="color" VALUE="red">
<INPUT TYPE="radio" NAME="color" VALUE="blue">
<INPUT TYPE="radio" NAME="color" VALUE="green">
<INPUT TYPE="radio" NAME="color" VALUE="yellow">

What is your favorite color?
red
blue
green
yellow

    To this purpose you will use a set of radio buttons. This name refers to radio with different presets, each setting a different channel. You can only listen to one channel at a time. Pushing one button will switch any other one off. All buttons in a set must have the same name. The values will probably differ, although that is not obligatory.

<INPUT TYPE="radio" NAME="color" VALUE="blue" CHECKED>

What is your favorite color?
red
blue
green
yellow

    If you have an idea what the most obvious answer is, you can set that as the default. Most people have blue as a favorite color. So I already set that on with the CHECKED attribute. If you use this attribute more than once, only the last one will be active. If you change the value, and then press the reset button, the default (checked) value will be selected again.

bottom  
left Copyright © Gerben Hoekstra - All rights reserved backnext right