Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML form with multiple hidden control elements of the same name

Is it legal to have an HTML form with more than one "hidden" control element with the same name? I expect to get the values of all of these elements at the server. If it is legal, do the major browsers implement the behavior correctly?

like image 338
Brian Avatar asked Jan 16 '09 21:01

Brian


People also ask

Can 2 elements have same name in HTML?

Yes. Show activity on this post.

Can two forms have the same name?

Only the name must be unique inside the form itself. See the docs: "The value must not be the empty string, and the value must be unique amongst the form elements in the forms collection that it is in, if any." This may be misleading.

How do I create a hidden text field in HTML?

The <input type="hidden"> defines a hidden input field. A hidden field let web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.


1 Answers

The browsers are OK with it. However, how the application library parses it may vary.

Programs are supposed to group identically named items together. While the HTML specification doesn't explicitly say this, it is implicitly stated in the documentation on checkboxes:

Several checkboxes in a form may share the same control name. Thus, for example, checkboxes allow users to select several values for the same property.

like image 60
Powerlord Avatar answered Sep 23 '22 08:09

Powerlord