aspose file tools*
The moose likes Servlets and the fly likes list values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

list values

phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
I have a drop down list like below

<select
<option> name = quater value= 1
Q1<option>
<select>

In the servlet or other jsp , If I want the Q1 not the values of Q1, How would I achieve this.

suppose like this
String quater = request.getParmatername();



thanks a lot
krishna kishore
Greenhorn

Joined: Oct 30, 2007
Posts: 19
one way is to store the option's text to a hidden component and take the value of the hidden from the request.
NOTE: onchange in combo(option) event, in javascript, assign the text to the hidden component.
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72

Check out

Class ServletRequest
Method: public java.util.Enumeration getParameterNames()


- Marimuthu Madasamy
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
The simplest and easiest is to place the Q1 as a value as well.
Is there any problem with that?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410



This is not a valid option tag or select tag.
Did you cut and paste this into Javaranch or did you type it yourself?
If the latter, please make sure that there are no typos in this code.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
Here is the code


I want to get the Q1,Q2,Q3 and Q4 not the values. What is the best way to do it?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

They're still malformed.
What does getSelection(1) return?
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
here is the code for getSelection()
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

So, it returns "SELECTED" or an empty string.

Browsers do not send the text of a select box option to the server, so you'll need to either map the values on the server or use Javascript to read the text for the given option and add it to the form submission. (as krishna mentioned)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

So why are you making the important dats not the value? Why do things the hard way? As said previously, make the value what you want returned. Simple.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
Is it possible to display web page in a table to show
row vertically and column horizontally

I want to show some thing like this

aaaa 1 2 3 43 4 4 4 4 4 4
bbbb 0 2 3 4 4 5 5 5 5 5 5
eeee 2 3 3 3 3 3 3 3 3 3
dddd 2 2 2 2 2 2 2 2 2 2 2

How would I write the code in all columns horizonatlly
and row vertically
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

This sounds like a completely different question.
It would be better it you started a new thread with it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: list values