This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Drop down Menu, Option,value  RSS feed

 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • 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>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks a lot for your response. Will give a shot at it.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • 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.
 
ranjan panda
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!