0

hi,
I have one drop down in my form. i want to access the selectd vaues from servlet. code in my servlet is:

String nval=request.getParameter("color");

in Jsp my code is:

............
 <select name="selectPrimaryKey">
<option>SelectValue</option>
<%
for (int i = 0; i < Nheadlist.size(); i++) {
	%>
<Option value="<%Nheadlist.get(i);%>"><%= Nheadlist.get(i) %>
</Option>
<%
}
%>
</select>

Can anyone please tell me how to get the selected value to the servlet........

thank you
regards
eclipse3.4ide

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by javaAddict
0

First of all the name of the select is: "selectPrimaryKey", so you will need something like this:

String nval=request.getParameter("selectPrimaryKey");

Also the select needs 1 minor change:

............
 <select name="selectPrimaryKey">
<option>SelectValue</option>
<%
for (int i = 0; i < Nheadlist.size(); i++) {
	%>
<Option value="<%= Nheadlist.get(i)%>" >
      <%= Nheadlist.get(i) %>
</Option>
<%
}
%>
</select>
This topic has been dead for over six months. 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.