单选按钮
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>单选按钮</title>
</head>
<body>
<form method="post" action="">
性别:
<input name="gen" type="radio" class="input" value="男">男
<input name="gen" type="radio" value="女" class="input">女
</form>
</body>
</html>
复选框
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>checkbox</title>
</head>
<body>
<form method="post" action="">
<input type="checkbox" name="interst" value="sports">运动
<input type="checkbox" name="interest" value="talk">聊天
<input type="checkbox" name="interest" value="play" checked="checked">玩游戏
</form>
</body>
</html>
区别:
单选按钮应具有相同的名称,便于互斥选择。
复选框的名称要根据应用环境来确定是否相同。
如果选项之间是并列关系,就需要设置为相同的名称,以便能够同时获取,例如一个人可以有多个爱好,设置相同名称后,在提交数据时能够一次性得到所有的兴趣爱好选项。