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:
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:
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!