HTML表单:为什么行动无法获得价值?

当我尝试以下结构时,它不会发送id = value
<form action="some.PHP?id=value" method="get">
   <input name="name1" value="value1">
   <input type="submit">
</form>

我知道我可以在隐藏字段中发送id = value,但它很有趣,为什么它不允许这样的结构?

解决方法

这是因为表单的“method = get”部分意味着查询值必须来自表单值.

包含“id = value”的集合将被包含表单值的集合覆盖.

这种行为似乎内置于每个浏览器中,因此我希望它是HTML规范的一部分.

更新

啊啊:

之前有人问过:
submitting a GET form with query string params and hidden params disappear

去引用:

正如规范(RFC1866,第46页; HTML 4.x第17.13.3节)所述:

If the method is “get” and the action is an HTTP URI,the user agent takes the value of action,appends a `?’ to it,then appends the form data set,encoded using the “application/x-www-form-urlencoded” content type.

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些