是否< input type =" checkbox" />只有发布数据,如果它被选中? [英] Does <input type="checkbox" /> only post data if it's checked?

查看:218
本文介绍了是否< input type =" checkbox" />只有发布数据,如果它被选中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在提交表单时检查复选框输入值数据,浏览器是否只需发送标准行为?

Is it standard behaviour for browsers to only send the checkbox input value data if it is checked upon form submission?

如果没有提供值数据,默认值总是on?

And if no value data is supplied, is the default value always "on"?

假设上述是正确的,所有浏览器都是一致的吗?

Assuming the above is correct, is this consistent behaviour across all browsers?

推荐答案

是的,标准行为是值只有在复选框被选中时才会发送。这通常意味着你需要有一个方法记住你期望在服务器端的复选框,因为并非所有的数据从表单返回。

Yes, standard behaviour is the value is only sent if the checkbox is checked. This typically means you need to have a way of remembering what checkboxes you are expecting on the server side since not all the data comes back from the form.

默认值是始终打开,这应该是跨浏览器一致。

The default value is always "on", this should be consistent across browsers.

这包含在 W3C HTML 4建议中


复选框(和单选按钮)是开关,用户可以切换
。当控制元素的选中
属性被设置时,开关是on。提交表单时,只有on复选框
控件可以成功。

Checkboxes (and radio buttons) are on/off switches that may be toggled by the user. A switch is "on" when the control element's checked attribute is set. When a form is submitted, only "on" checkbox controls can become successful.

这篇关于是否< input type =" checkbox" />只有发布数据,如果它被选中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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