checkbox复选框获取多选项

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
</head>
<h1>用户注册</h1>
<form action="register2.php" method="post">
用户名:<input type="text" name="username"/><br/>
密码<input type="password" name="passwd"/><br/>
性别:<input type="radio" name="sex"  value="female" />女 <input type="radio" name="sex"  value="male" />男<br/>
你喜欢什么:
<input type="checkbox" name="hobby[]" value="唱歌">唱歌
<input type="checkbox" name="hobby[]" value="跳舞">跳舞
<input type="checkbox" name="hobby[]" value="游泳">游泳
<input type="checkbox" name="hobby[]" value="骑马">骑马
<br/>

需要在hobby后加[]就可以

posted @ 2018-02-14 09:14  TangYJun  阅读(299)  评论(0)    收藏  举报