如何保存未经检查的动态复选框数组?

时间:2017-03-02 19:58:01

标签: javascript php html checkbox

我有这个html代码,其副本数量与用户想要的一样多,但是添加了另一组的按钮

<input type="email" class="regular-text" id="customer_email_address[]" name="customer_email_address[]" placeholder="Email Address" />
<input type="text" class="regular-text" id="customer_email_password[]" name="customer_email_password[]" placeholder="Password" />
<input type="checkbox" id="customer_email_create[]" name="customer_email_create[]" />

我的问题是,虽然我可以保存使用PHP检查的复选框,但我无法确定哪些是未选中的。

我将如何做这样的事情?

1 个答案:

答案 0 :(得分:0)

例如,您可以检查customer_email_create值。如果它为空,则取消选中该复选框。

编辑:

由于值是数组,因此在每次数据更新时,您都必须删除与数据库相关的所有数据,并从POST请求中添加新数据。