Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 4 votes, 4.00 average. Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 26th, 2001, 04:30 PM
wgblackmon wgblackmon is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 2 wgblackmon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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.





Reply With Quote
  #2  
Old January 29th, 2001, 05:09 PM
merkinmuffley's Avatar
merkinmuffley merkinmuffley is offline
film at 11
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Portland, OR
Posts: 413 merkinmuffley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
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.


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Retreiving values from a combo box/select

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap