今天写php的时候发现$_POST["arr"]无法获取参数arr的数组,记录一下。

 例如有以下表单需要提交:

  <input type="checkbox" name="arr" value="" />

  <input type="checkbox" name="arr" value="" />

  <input type="checkbox" name="arr" value="" />

  <input type="checkbox" name="arr" value="" />

 使用$_POST["arr"]只能获得最后选择的复选框的值,要获得全部选中的复选框的值需要把表单修改成下面:

  <input type="checkbox" name="arr[]" value="" />

  <input type="checkbox" name="arr[]" value="" />

  <input type="checkbox" name="arr[]" value="" />

  <input type="checkbox" name="arr[]" value="" />

这样就可以使用$_POST["arr"]获得全部选中的checkbox的值了。

相关文章:

  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
猜你喜欢
  • 2021-05-02
  • 2022-01-08
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2021-12-05
  • 2021-05-13
相关资源
相似解决方案