aspose file tools*
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
Author

Problem in Form List Box

Vignesh Babu M.J.
Greenhorn

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:

test.html


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

test.java ( 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
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

<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] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem in Form List Box