aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Two value to be passed in select Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Two value to be passed in select" Watch "Two value to be passed in select" New topic
Author

Two value to be passed in select

meena latha
Ranch Hand

Joined: Jan 24, 2005
Posts: 219
Hi all.
I am using JSTL for my JSP.
In my select list i need to pass two value.
For example.



This will allow me to get only the id .But i want to get the selected Name also.Basically i wanted both the id and name .Is there any way to do this.
I know there is <c:forTokens> but dont know how to use it.

thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61429
    
  67

This really has nothing to do with JSP, JSTL or anything on server side.

Moving to the HTML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61429
    
  67

Regardless of how you construct the HTML on the server side, when a select element is submitted, it will submit the value of the selected option, not the option text.

If you need that as well (seems like a pretty poor design to me, a properly constructed model should be able to pull up any information using the id as the primary key of the element), you will need to write an onsubmit handler that can find the text of the selected option and copy it to a hidden element in your form so that it will get submitted in addition to the option value.
meena latha
Ranch Hand

Joined: Jan 24, 2005
Posts: 219
Thanks for the logic .
It is working fine.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Two value to be passed in select