• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Two value to be passed in select

 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This really has nothing to do with JSP, JSTL or anything on server side.

Moving to the HTML forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the logic .
It is working fine.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic