使用表单来解决问题
<!--
form表单标签
属性:
1、action:将表单的数据提交至什么地址
2、提交的方法,get,post
get方法,将表单的数据直接放置到链接地址上,可以直接看的到。不安全,但效率高
post方法,表单数据放置到请求的body里面,不直接显示,安全,但效率稍微低,可以表单的数据可以提交比较大。
input标签
属性:
type:定义输入标签的类型、text/password/submit
name:提交数据的名称
value:提交数据的输入框的值
placeholder:预置文字
-->
1.单选框
type的值是radio,单选框,name值一样,两个只能选择一个
<input type="radio" name="gender" />
2.复选框
type的值是checkbox,复选框,name值一样,可以选择多个
<input type="checkbox" name="gender" />
例子:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form action="" method="post">
<input type="text" name="username" id="" value="" placeholder="账号" />
<input type="password" name="password" placeholder="密码"/>
<hr >
男
<!-- radio是单选框,name值一样,两个只能选择一个 -->
<input type="radio" name="gender" />
女
<input type="radio" name="gender" id="" value="" />
<hr >
<h3>请选择你喜欢的城市</h3>
南京
<!--checkbox是复选框,name值一样,可以选择多个 -->
<input type="checkbox" name="wq" id="" value="" />
徐州
<input type="checkbox" name="wq" id="" value="" />
苏州
<input type="checkbox" name="wq" id="" value="" />
<hr>
<input type="submit" id="" name="" value="注册" />
</form>
</body>
</html>