• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in Form List Box

 
Vignesh Babu M.J.
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic