如何在POST中发送所有复选框? [英] How to send all checkboxes in POST?

查看:182
本文介绍了如何在POST中发送所有复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单中有10个复选框。只有选中的复选框才会发送到POST。如何将所有复选框发送到POST,beacouse我想做指示更改为检查并更改为没有选中复选框。
如何做?

I have 10 checkboxes in a form. Only checked checkboxes are sending to POST. How to send all checkboxes to POST, beacouse I want to do instruction for changed to checked and changed to no checked checkbox. How to do it?

推荐答案

正如我在评论中所说的,浏览器只会发送选中的复选框并永远不会发送所有复选框。你可以做的是检查PHP如果复选框存在于 $ _ POST $ _ GET 变量和行为

As I already stated in a comment, the browser will only send the checked checkboxes and will never send all checkboxes. What you can do is to check with PHP if the checkbox is present in the $_POST or $_GET variable and act according to the present state.

如果您使用PHP脚本动态生成复选框,则可以使用包含所有复选框名称的序列化数组来创建隐藏框,以检查和那么你只能循环通过它,并在验证脚本中检查他们的状态。

If you dynamically generate the checkboxes with a PHP script, you can make a hidden box with a serialized array with all the checkbox names to check and then you can only loop through it and check their states later on in the validation script.

由于你没有提供任何代码,我不能帮助你,进行任何改进。

Since you didn't provide any code I can't help you with it or make any improvements.

这篇关于如何在POST中发送所有复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆