<html xmlns="http://www.jb51.net/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>php获取 checkbox复选框值的方法</title>
</head>
<body>
<form name="form1" method="post" action="">
<label>
<input type="checkbox" name="checkbox[]" value="复选一">
复选一
</label>
<label>
<input type="checkbox" name="checkbox[]" value="复选二">
</label>
复选二
<label>
<input type="checkbox" name="checkbox[]" value="复选三">
</label>
复选三
<label>
<input type="checkbox" name="checkbox[]" value="复选四">
</label>
复选四
<label>
<input type="submit" name="Submit" value="提交">
</label>
</form>
</body>
</html>
<? php
if( $_POST )
{
$value = $_POST['checkbox'];
echo '你选择了:'.implode(',',$value);
//由于checkbox属性,我们必须把checkbox复选择框的名字设置为一个如果checkbox[],这样php才能读取,以数据形式,否则不能正确的读取checkbox复选框的值哦。
}
?>