【发布时间】:2016-08-14 03:24:49
【问题描述】:
我有多个动态创建的表单域。
<label><input type="text" name="txtAmt[]">Amount</label>
<label><input type="checkbox" name="cbMarkPaid[]">Mark as Paid</label>
我使用 post 方法将 for 提交到 php 文件。我知道复选框不会在您未选中时将数据发送到服务器。但我想知道未选中的复选框的索引.
例如如果我有 4 个复选框 cb1,cb2,cb3,cb4 并且如果 cb3,cb4 被选中。然后 php 收到一个包含两个项目的数组:
array(2) { [0]=> string(2) "on" [1]=> string(2) "on" }
但我希望数组为:
array(2) { [0]=> string(2) "off" [1]=> string(2) "off" [2]=> string(2) "on" [3]=> string (2) “开”}。
请不要isset($_POST['cbMarkPaid'][]) 也给出相同的输出
谢谢
【问题讨论】:
-
共享完整标记...您只提供了 2 个字段...
标签: javascript php arrays html checkbox