• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Drop down Menu, Option,value

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Folks,
Is there a way I can get the Option that has been selected in the page. I know that we can get optionValue by request.getParameter("dropDown"); I want to able to capture the option also i.e if the user selects <option value="1">first</optiont>, can I get Option name "first" that the user has selected?

<select name="dropDown">
<option value="1">first</optiont>
<option value="2">second</optiont>
</select>
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using a bean to populate the dropdown, you can get the string back again using the value which has been sent.
The string inside the option tag is not send in the request, so I think you'll have to use a bean or an array or whatever you want to contain the dropdown information.
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your response. Will give a shot at it.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Satou kurinosuke:
The string inside the option tag is not send in the request, so I think you'll have to use a bean or an array or whatever you want to contain the dropdown information.



I think using a Map is a better idea.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I konw you till now did not get the appropriate answer.
See you have two options;
1. Create a mapping file which hold the drop down value as a key and option name as a map value.
2. Change the name of the option value itsefl to something relevvant which you can use.

There are no methods as such to do it.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ranjan panda:
I konw you till now did not get the appropriate answer.



Excuse me? How have the answers to date not been appropriate?


1. Create a mapping file which hold the drop down value as a key and option name as a map value.



Why would a file be used?


2. Change the name of the option value itsefl to something relevvant which you can use.



May not be appropriate if the values are dictated by the back end and it's rather silly to constrain the values in such a way needlessly.
[ May 22, 2006: Message edited by: Bear Bibeault ]
reply
    Bookmark Topic Watch Topic
  • New Topic