permaculture playing cards*
The moose likes Servlets and the fly likes Multiple Drop Down Boxes With same name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Multiple Drop Down Boxes With same name" Watch "Multiple Drop Down Boxes With same name" New topic
Author

Multiple Drop Down Boxes With same name

Johnny Ganestruep
Greenhorn

Joined: Nov 22, 2010
Posts: 3
Hello I have multiple drop down boxes with the same name. In the case of a single drop down box one would use getparametervalues(). How would I retrieve multiple drop down box values in a servlet with the same name if 2 dimensional array are not possible?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

"Johnny WalkerTheInfamous",
Welcome to the ranch ! Please check your Private Messages for an important administrative matter.


[My Blog]
All roads lead to JavaRanch
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Johnny Ganestruep wrote:Hello I have multiple drop down boxes with the same name. In the case of a single drop down box one would use getparametervalues(). How would I retrieve multiple drop down box values in a servlet with the same name if 2 dimensional array are not possible?


You need to provide unique names for each Drop down.


Mohamed Sanaulla | My Blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

mohamed sanaullah wrote:You need to provide unique names for each Drop down.

Not correct.

If there are multiple elements with the same name -- which is perfectly valid -- their values will be returned as an array by getParameterValues().


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Bear Bibeault wrote:
mohamed sanaullah wrote:You need to provide unique names for each Drop down.

Not correct.

If there are multiple elements with the same name -- which is perfectly valid -- their values will be returned as an array by getParameterValues().


I meant different name for each drop down (and not for the options in the drop down). Say there are different <select> tags- each select will have a different name.

Or even in this case same name is sufficient?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

mohamed sanaullah wrote:I meant different name for each drop down (and not for the options in the drop down). Say there are different <select> tags- each select will have a different name.

Not correct.

Any number of elements within a form can have the same name. Do not confuse name with id, which must be unique.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Bear Bibeault wrote:
mohamed sanaullah wrote:I meant different name for each drop down (and not for the options in the drop down). Say there are different <select> tags- each select will have a different name.

Not correct.

Any number of elements within a form can have the same name. Do not confuse name with id, which must be unique.


Oh ok, thanks for the clarification.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Multiple Drop Down Boxes With same name