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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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: 56204
    
  13

<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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Problem in Form List Box
 
Similar Threads
Listbox shrinking in IE7
SELECT boxes in Netscape
JSP -- spaces in parameters not fully working from listbox
Having trouble with javascript ...
Passing multiple listbox to bean using JSP