为什么 html 复选框只传输“on"值? [英] Why do html checkboxes only transmit an 'on' value?

查看:21
本文介绍了为什么 html 复选框只传输“on"值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习互联网编程.

I'm just starting to learn internet programming.

在使用复选框之后,我发现了一个艰难的方法,只有当复选框被选中时,它才会传输一个on"值.

After playing around with checkboxes, I found out the hard way, that it is only when the checkbox is checked that it transmits an 'on' value.

为什么不也发送一个关闭"值?

Why not also send an 'off' value?

推荐答案

我认为必须是为了传输的简洁.如果您有一个包含数千个复选框的页面,则发送到服务器的每个请求都会通过网络"发送,您会发现告诉服务器此框已关闭"的数据量实际上相当大(请参阅就像您必须发送每个复选框元素的名称一样 - 这可能会增加数兆字节的信息 - 这会降低整个用户体验和互联网速度).

I think it must be for brevity of transmission. Each request to the server is sent 'over the wire' if you've got a page with thousands of checkboxes on it, you will find that the amount of data to tell the server "this box is off" is actually quite sizeable (seeing as how you'd have to send the NAME of each checkbox element - that could add up to megabytes of information - which would slow the entire user experience & internet down).

事实上,您知道它是关闭的,因为它没有被发送 - 所以没有必要发送它.

Whereas in fact you know that it is off by virtue of it not being sent - so there's no need to send it.

这篇关于为什么 html 复选框只传输“on"值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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