表单元素命名大小写和重复? [英] Form elements naming case and duplication?

查看:115
本文介绍了表单元素命名大小写和重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的表单有2个输入

Let say my form has 2 inputs

<input name="person_name" value="John" type="text" />
<input name="person_name" value="Jean" type="text" />

提交表单时,我会得到哪个person_name? John或Jean?

When submit the form, which "person_name" will I get? John or Jean?

如果我有

And if I have

<input name="city" value="New York" type="text" />
<input name="City" value="New York" type="text" />

我会得到城市或城市还是两者?

Will I get just "city" or "City" or both of them?

推荐答案

您将得到两个 person_name 值(即John和Jean) ,那么由服务器决定如何处理它。你可以在你想要的同名表格中包含尽可能多的元素; [] 表示法只是一些框架用来将表单的结构传递给服务器的标记,这样服务器就可以在没有额外指令的情况下解压它,也不需要程序员不必区分一个包含一个值和一个值的列表。

You will get two person_name values (i.e. both John and Jean) sent to the server, then it is up to the server to figure out what to do about it. You can have as many elements in a form with the same name as you want; the [] notation is just notation that some frameworks use to pass the form's structure to the server so that the server can unpack it without extra instructions and without the programmer having to differentiate between a list with one value and a single value.

您还将获得单独的 city City 参数,再次,它将由服务器代码来确定它是如何处理它的。

You'll also get separate city and City parameters and again, it will be up to the server code to figure out how it wants to handle that.

从< a href =http://www.w3.org/TR/html4/interact/forms.html#successful-controls =nofollow> HTML4标准:

From the HTML4 standard:


每个成功的控件都将其控件名称与其当前值配对,作为提交的表单数据集的一部分。一个成功的控件必须在FORM元素中定义,并且必须有一个控件名称。

Every successful control has its control name paired with its current value as part of the submitted form data set. A successful control must be defined within a FORM element and must have a control name.

没有任何内容只选择一个文本输入从几个具有相同的名称属性。

There's nothing in there about selecting only one text input from several with the same name attribute.

这篇关于表单元素命名大小写和重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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