Home >Web Front-end >HTML Tutorial >How to implement the radio button function in html page? (example)

How to implement the radio button function in html page? (example)

藏色散人
藏色散人Original
2018-08-15 10:09:2110418browse

During our website construction process, some website content requires the design of some survey forms, so the design of the selection box is indispensable. Since there are options, there is the problem of single or multiple selection. Therefore, this article will mainly introduce to you the related issues about how to determine the radio button in HTML.

1.html Radio button gender selection example is as follows:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>html单选联动示例</title>
</head>
<body>
您的性别:
<input type="radio" name="activity" value="男">男
<input type="radio" name="activity" value="女" >女
<br/> <br/><br/>
</body>
</html>

The effect is as follows:

How to implement the radio button function in html page? (example)

The above is an example of html radio button selecting gender.

2.html Single selection and a default value example is as follows:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    你是否喜欢旅游?
    <input type="radio" name="activity" value="喜欢" checked="checked">喜欢
    <input type="radio" name="activity" value="不喜欢" >不喜欢
    <input type="radio" name="activity" value="随便" >随便
   <br/> <br/><br/>
</body>
</html>

The effect is as follows:

How to implement the radio button function in html page? (example)

The above is an example of html radio selection and defaulting to a value. Here you can find a significant difference from the above code example 1, the checked attribute.

The checked attribute specifies the input elements that should be pre-selected when the page is loaded. Use with or . It can also be set via JavaScript code after the page loads.

Then this article introduces the related issues of how to determine the radio button box in HTML. It has certain reference value and I hope it will be helpful to friends in need.




The above is the detailed content of How to implement the radio button function in html page? (example). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn