File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Catching the content of drop down box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Catching the content of drop down box" Watch "Catching the content of drop down box" New topic
Author

Catching the content of drop down box

Prasad Darsi
Greenhorn

Joined: Sep 26, 2004
Posts: 16
I declared the drop-down menu as shown below:

<form name="myForm" action="form2.jsp">
<select name="Fruits">
<option value="" selected>Select A Fruit</option>
<option value="1">Orange</option>
<option value="2">Apple</option>
<option value="3">Banana</option>
</select>
<input type="submit" value="Submit">
</form>

After submitting the form, I am catching the value of "Fruits", and it is showing either 1,2, or 3.

I want to catch both the value and its content in "form2.jsp" so that I can post that data in the database. When the form is submitted, The value of "Fruits" is showing one of 1,2 or 3.

Is there anyway by which I can catch both the content of the drop-down box ?

Thanks in advance,
Prasad.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
This is a jsp question, moving there.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61774
    
  67

The display text of the drop-down box is not submitted.

Presumably, you already have this info on the server so that you could generate the select element in the first place. Use the submitted value to look up the corresponding text.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Prasad Darsi
Greenhorn

Joined: Sep 26, 2004
Posts: 16
I can fetch this value from the server by using one more query. But to do this, I have to access the database again.

Can we avoid this database access, so that I can get these two values quickly ? (I can also save some lines of code)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Catching the content of drop down box