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.

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?

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

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!

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.