Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

select a value from a drop down menu bar in a HTML page

 
Mayank Adhikari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I wish to select a value from a drop down menu bar in a HTML page and then pass the value to some other jsp page where it will be used as an input to a sql query.
But when i am check the input in jsp page then it is showing empty value.


MY DROP DOWN HTML is as below

<form method="post" action="test.jsp" onsubmit="return validLogin();">
<select name="Employee">
<option value="opt1" name="username">opt1</option>
<option value="opt2" name="username">opt2</option>
<option value="opt3" name="username">opt3</option>
</select>
<input type="submit" value="sub"/>
</form>

MY JSP PAGE: test.jsp

<%
System.out.println("Oracle Connect Example.");
try {
String username = request.getParameter("username");
out.println(username);
}
%>


Please any suggestion on this will be highly appreciated.



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
option elements do not have names. Only the select element has a name.
 
Mayank Adhikari
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot it worked
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic