java - How to set value on select change of drop down in JSP -


this code index.jsp. want when select option in drop-down menu, value should printed out , value should set. example, if select "grapes" should print grapes , set value grapes. have tried many things have been unable so.

<html> <head>     <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">     <title>insert title here</title> </head> <body>     <form method="post" action="index.jsp" name="productform">     <select name="colour" onchange="document.productform.submit();">         <option value="dropdown">pls select 1         <option value="apple">apple         <option value="oragne">orange         <option value="grapes">grapes     </select>     <input type="hidden" name="dropdown" id="dropdown">     <input type="submit" value="click" name="dropdown" id="dropdown">     <form>     <%         string colour = request.getparameter("colour");         out.println(colour);     %> </body> </html> 

1st thing first, if want set value dropdown on change of value, itself. if want set value selected session, again have use request.getparameter(color) on next page or backend processing request. printing on console, have correct code. close tags properly.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -