?
Solved

How to get display string in a select control

Posted on 2009-04-27
2
Medium Priority
?
380 Views
Last Modified: 2012-05-06
Hi Experts,

Please help me on below simple problem, thanks!
I have an JSP page, submit on itself, and a select control on it. My problem is how to get select control's display string, not it's value.
<body>
   <%
      // Get myList display string (One, Two, or Three). How?
      String selectedValue = request.getParameter("myList");
      // String selectedString = request.getWhat? 
   
      out.println(selectedValue );
      out.println(selectedString );
   %>
 
   <select name="myList" id="myList">
      <option value="1">One</option>
      <option value="2">Two</option>
      <option value="2">Three</option>
   </select>
</body>

Open in new window

0
Comment
Question by:ncsvietnam
2 Comments
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 1500 total points
ID: 24247767
you can not get the "String" value on the request parameter... however, you can code your value to contain both the value and the display string.. something like below code..



<body>
   <%
      // Get myList display string (One, Two, or Three). How?
      String selectedValue = request.getParameter("myList");
     String[] myvals = selectedValue.split("-");   
      out.println(myvals[0] );
      out.println(myvals[1] );
   %>
 
   <select name="myList" id="myList">
      <option value="1-One">One</option>
      <option value="2-Two">Two</option>
      <option value="3-Three">Three</option>
   </select>
</body>

Open in new window

0
 

Author Closing Comment

by:ncsvietnam
ID: 31575310
OK
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question