File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Problem in Form List Box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Problem in Form List Box" Watch "Problem in Form List Box" New topic

Problem in Form List Box

Vignesh Babu M.J.

Joined: May 13, 2008
Posts: 5
Hi all,

I have one listbox( in form ) with multiple selection option. upon clicking submit button this form will send details to servlet program. The problem here for me is ,
whichever is selected in listbox, that only am getting in servlet side.

Is it possible to get all the values from list box even without single selection.

Sample Code:


<FORM NAME="test" ACTION="/servlet/test" METHOD="POST">
<select size="8" name="list" multiple>
<option>Test One </option>
<option>Test Two </option>
</form> ( servlet program )

String[] listVal = request.getParameterValues( "list" );

if no item is selected in listbox, am getting null value in servlet side,
is it possible to get all values even without single selection in list box?

can any one help me ?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

<select> elements will, by their definition, only send the values of selected option elements as part of a form submission. If you want all the option values sent, you can either: select them under script control when the form is submitted, or you can copy all the option values to hidden elements that will be submitted.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Problem in Form List Box
It's not a secret anymore!