aspose file tools
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
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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: 109
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: 56153
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 109
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: Multiple form elements with same name
 
Similar Threads
Arrays in struts ActionForm showing '[Ljava.lang.String;@10321032'
Need help to correct @JoinColumn mapping in entity class with composite keys
geting focus on radio button
table not mapped error when compiling entity bean
Loading multiple forms in single jsp