Tuesday, 10 September 2013

Get selected value from HTML - -- box

Get selected value from HTML - -- box

I am dealing with a web application. I have a HTML - select box with 50k
string values. From these 50k values user will select one and I want to
use that selected value in a SQL where clause for further retrieval. But
right now with existing code I am getting null. Code looks like -
out.println("<form action=sampleServlet method=POST>");
out.println("<select name=\"data\">");
for(int i=0;i<nw.collectdata.length;i++)
{
out.println("<option
value='"+nw.collectdata[i]+"'>"+nw.collectdata[i]+"</option>");
}
out.println("</select>");
out.println("<button type='submit'>Submit</button>");
out.println("</form>");
elements = request.getParameter("data");
out.println(elements);
elements is returning null and not selected value.

No comments:

Post a Comment