php checkbox 复选框

摘要:
在给checkBox命名时,必须要加"[]",但是在接收时不能加"[]"才能得到值!例如:html代码1  2  3result.php代码:˂?

在给checkBox命名时,必须要加"[]" ,但是在接收时不能加"[]" 才能得到值!

例如:

html代码

<html>
<head>
<body>
<form action="result.php" method="POST">
<input type="checkbox" name="year[]" value="1">1 &nbsp;&nbsp;
<input type="checkbox" name="year[]" value="2">2 &nbsp;&nbsp;
<input type="checkbox" name="year[]" value="3">3 <br>
<input type="submit" name="btn_ok" value="ok">
</form>
</body>
</head>
</html>

result.php 代码:

<?php
foreach ($_POST['year'] as $item)
{
echo $item."<br>";
}
?>

免责声明:文章转载自《php checkbox 复选框》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Linux下RocksDB、LevelDB、ForestDB性能测试对比golang-函数下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

input 时间字段默认值

背景: 时间字段展示默认值,开始时间为当天 0点,结束时间为当天晚上12点 代码: 1 <input style="Width: 180px;float:left ;" type="date" id="start_time" 2 name="start_time" placeholder="请选择具体时间" data-format="YYY...

&amp;lt;input /&amp;gt;

H5新增input的属性 <input type="number" min="2" max="10" step="2"/> 上下加减 <input type="range" min="2" max="10" step="2"/> 进度条 <input type="search"/> text可以点删除 <inpu...

submit提交表单后,不刷新当前页面

<form method="get" target="test" action="a.html"> <input type=""text /> <input type="submit" /> </form> <iframe name="test" style="display:none">...

web自动化测试---css方式定位页面元素

  css方式定位的方法也有很多,相较于xpath更灵活一点,下面就介绍下使用方法(以百度输入框为例) 1、通过tag来定位,可以写成如下: driver.find_element_by_css_selector('input').click()  这里要说明的是tag为input的必须唯一才能这么写,否则可以用其他方式定位 2、通过id来定位,可以写成...

网站开发常用技巧收集(防复制,防另存等等)

1. 将彻底屏蔽鼠标右键 oncontextmenu="window.event.returnValue=false" 用于Table <table border oncontextmenu=return(false)><td>no</table> 2. 取消选取、防止复制 <body onselectstar...

图片右上角添加删除

一、css /*图片适用大小*/ img { width:100%; height:100%; } .imgAll li { /*图片容器position: relative属性*/ width:100px; height:100px; bor...