HTML Radio Buttons option buttons



 Radio Buttons are used in HTML forms to allow netizens to select one item at a time, and only one item can be selected. If you want to select multiple items, you can use Checkboxes instead of Radio Buttons option buttons. When you set a group of Radio Buttons, the name is all At the same time, netizens can only choose one of the items for this group of Radio Buttons.


HTML Radio Buttons option button example
<form>
Please select the residential area<br>
<input type="radio" name="location" value="Taipei"> Taipei<br>
<input type="radio" name="location" value="Taoyuan"> Taoyuan<br>
...
</form>
The results are presented as
Please select a residential area
 Taipei
Taoyuan
...

In this example, we set the place names of various regions in Taiwan to allow netizens to choose where to live. In order to shorten the length, only the two regions of Taipei and Taoyuan were written. You can see that the basic wording of Radio Buttons is <input type="radio"> like this, which contains two key points: name and value. We set name="location" uniformly, which means this is a group of option buttons, so netizens Only one region can be selected at a time, and the value is the value of the option. This value is used for reading by programs such as PHP after the form is sent , and netizens will not see it on the web page.

Radio Buttons option buttons are often mixed and used with Checkboxes checkboxes. The difference in application is that Radio Buttons usually use single selection, while Checkboxes are often used when many items can be selected. How to consider depends on the requirements of the form design at the time .

Post a Comment

0 Comments