Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes Multiple form elements with same name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Multiple form elements with same name" Watch "Multiple form elements with same name" New topic
Author

Multiple form elements with same name

Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
My page consists of several different forms. 4 of these forms has an element in common (customerNumber). All forms are rendered in HTML, but not all are shown(all but one is hidden).

So when I submit the form that is shown does not retain the value within its customerNumber. When I tried to rename its name it worked, but I would like to reuse the name, instead of having multiple names for the same purpose value element.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

By "name" do you mean name or id?

There is no problem having multiple elements with the same name, even within the same form. id is a different matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
Originally posted by Bear Bibeault:
By "name" do you mean name or id?

There is no problem having multiple elements with the same name, even within the same form. id is a different matter.


When I used the same name on similar form elements, then on submit those values did not make it to the Servlet. Only when I renamed them with unique name it worked.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
How do you try to get the values in your servlet ?


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
jQuery in Action, 2nd edition
 
subject: Multiple form elements with same name