|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I have a combo box/select field. I need to retrieve
the text contents of the selected field and assign it to a Java String variable within a servlet. Give that the name of the field is defined as within the servlet body: out.println("<select name='generation_type'>"); How can I get a handle on the contents and assign it to a String value, as in String sSelect = <Contents of Select Field> Also, is there a way to show a String value in an option value as well as assign a hidden field like the String values ID (primary key) and return the ID rather than the selected text? I've done this with VB, Access and JFC but have no idea how to do in HTML/JavaScript. Any pointers to good books on this subject would be greatly appreciated. |
|
#2
|
||||
|
||||
|
If you have a dropdown combo box called "generation_type", you can access the choice the user made in the servlet that handles the post/get request by:
String gen_type = request.getParameter("generation_type"); This will help you out (check out the javax.servlet.http package, which contains reference material for the HttpServlet class and HttpServletRequest interface): http://java.sun.com/products/servle...adoc/index.html I'm not sure what you mean by the second part of your question, but I think it's this: If i have a hidden value like <input type="hidden" name="hid_val"...>, then you get the value the same way as above: String hiddenval = request.getParameter("hid_val"); This is all assuming, of course, that you named the HttpServletRequest object "request" in your doGet() or doPost() method. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Retreiving values from a combo box/select |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|