#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    2
    Rep Power
    0
    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. #2
  3. film at 11
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Portland, OR
    Posts
    413
    Rep Power
    14
    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/servlet...doc/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.


IMN logo majestic logo threadwatch logo seochat tools logo