HTML表单:为什么行动无法获得价值? [英] HTML Form: why action can't have get value in it?

查看:134
本文介绍了HTML表单:为什么行动无法获得价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试以下结构时,它不会发送 id = value

 < form action =some.php?id = valuemethod =get> 
< input name =name1value =value1>
< input type =submit>
< / form>

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

解决方案

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

包含id = value的集合由包含表单值的集合覆盖。

这种行为似乎是嵌入到每个浏览器中的,所以我期望它是HTML规范的一部分。

更新



ahah:

之前已经询问过:
提交带有查询字符串参数的GET表单和隐藏的参数消失



要引用:



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


如果方法是get,action是一个HTTP URI,用户代理接受action的值,附加一个'?',然后附加表单数据集,使用application / x-www-form-urlencoded 内容类型。



When i try the following structure, it does't send id=value

<form action="some.php?id=value" method="get">
   <input name="name1" value="value1">
   <input type="submit">
</form>

I know that i can send id=value in hidden field, but it's interesting, why it doesn't allow such structure?

解决方案

It's because the "method=get" section of the form implies that the query values have to come from the form values.

The collection which contains "id=value" is overidden by the collection containing the form values.

This behaviour seems to be built into each browser, so I expect that it's part of the HTML specification.

Update

Ahah:

This has been asked before: submitting a GET form with query string params and hidden params disappear

To Quote:

As the specifications (RFC1866, page 46; HTML 4.x section 17.13.3) state:

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.

这篇关于HTML表单:为什么行动无法获得价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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