0

Hi I have a Select element in my page,

It looks like this

<select name="test">
  <option value="1">Hi</option>
  <option value="2">Hello</option>
  <option value="3">GoodBye</option>
</select>

Ok, don't mind the syntax or if I missed something, everything works fine, the problem is that I want to get the selected option value from a servler.

If I do request.getParameter("test");

I think I'm getting the HI instead of the value "1"... How can I get the selected option value?

Thanks in advance.

4
Contributors
5
Replies
8
Views
6 Years
Discussion Span
Last Post by vinay.yash.3
0

I believe that the request.getParameter("test") will give you the value "1", not the "Hi". Why do you think that it is not working?

0

Yes, sorry, I realized the problem was not there, I just had my sql statement wrong :S, thanks anyway.

0

Hello everyone!

I'm facing a similar problem. How about getting the value of a <select> in the same .jsp?
With this value, I need to creat/fill another <select>

Thanks!

0

Hi,

I suggest you search for cascading selects or cascading drop down lists, drop down lists are for asp.net but I guess there is a similar workaround for Select tags.

0

servlet coding:

1.use list in servlet
ArrayList s1=new ArrayList();
2.add the request value in list
s1.add(request.getParameter("usertype"));
3.and the use the out.print("s");
thats all

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.