PHP checkbox全选及提交到PHP

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script>
function checkAll(obj,names){
	var checkboxs = document.getElementsByName(names);
	for(var i=0;i<checkboxs.length;i++){checkboxs[i].checked = obj.checked;}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="manage.php">
	<table width="100%">
	<tr>
		<td>
			<input type="checkbox" name="checkbox[]" value="a" />甲类 
			<input type="checkbox" name="checkbox[]" value="b" />乙类 
			<input type="checkbox" name="checkbox[]" value="c" />丙类
		</td>
	</tr>
	<tr>
		<td><input type="checkbox" name="pointall" onclick="checkAll(this,'checkbox[]')" />全选/取消</td>
	</tr>
	<tr>
		<td><input type="submit" name="Submit" value="提交" /></td>
	</tr>
	</table>
</form>
</body>
</html>

效果图:

 

<?php
	print_r($_POST[checkbox]);
?>

效果图:

 

PS:兼容IE6+,火狐 ,谷歌,欧朋

猜你喜欢

转载自onestopweb.iteye.com/blog/2356458
php