wood burning stoves 2.0*
The moose likes Servlets and the fly likes Select value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Select value " Watch "Select value " New topic
Author

Select value

vasuma patel
Greenhorn

Joined: Mar 07, 2006
Posts: 15
How do I get the selected value of a dropdown box( HTML select) from request object?

Thanks in advance

Vasuma
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

With getParameter() just like any other form element.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Note that you'll get the value of the selected option, not the text displayed in the combobox.


[My Blog]
All roads lead to JavaRanch
vasuma patel
Greenhorn

Joined: Mar 07, 2006
Posts: 15
Ok.. Thanks. I was using getParameter() but am getting null and so thought there is something different to do with select. I will check what I was doing wrong.
Uma Mahi
Ranch Hand

Joined: Jan 11, 2006
Posts: 34
<option value="test">test</option>

set the value attribute for the option tag


Umaa Mahi<br />--SCJP1.4
sushma sree
Greenhorn

Joined: Mar 27, 2006
Posts: 12
Your code should look something like this:

<select name="selectedItem">
<option value="1">Value1</option>
<option value="2">Value2</option>
</select>

And in your code, you can retrieve it using

request.getParamter("selectedItem");

Incase you have a list box rather than a select box like

<select name="selectedItems" multiple>
<option value="1">Value1</option>
<option value="2">Value2</option>
</select>

your code should then be

request.getParameterValues("selectedItems");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Select value
 
Similar Threads
drop down box
how to reset a selected list box item after search
combo value not select after submit
Combo box
Selecting value in html:optionCollections