Select all PHP checkboxes and submit to 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>

Effect picture:

 

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

Effect picture:

 

PS: Compatible with IE6+, Firefox, Google, Opera

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326964109&siteId=291194637