This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes how to dispaly the selected value of a dropdown list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to dispaly the selected value of a dropdown list " Watch "how to dispaly the selected value of a dropdown list " New topic
Author

how to dispaly the selected value of a dropdown list

rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
hi every body...

can you please suggest me how to display the selected value of a drop down list of a page...when we visit that page again.

actually i got some material on net but don't know how to use it.

the link i follwed was

webpage


i will just give you an examlple..


say my drop down list is



now say if i select UK from this.....and i visit this page next time it should show me the "UK" as the selected option

In the link which i followed ..they have used



but i don't know how to use it.

can any body help me.....is there any other way to get the result....what i have been using earlier was puuting all the options in an array...and then comparing the selected value with all the elements ...and whichever matches ..that option was put as selected.
but i want other way...please help .

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Simply set the attribute selected="selected" on the option that you want.

That code you downloaded looks pretty useless as it uses a lot of proprietary classes that don't exist in the Servlet/JSP environment.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Bear Bibeault wrote:That code you downloaded looks pretty useless as it uses a lot of proprietary classes that don't exist in the Servlet/JSP environment.


Not surprising for a site named "dotnetspider.com", really. Reading a .Net forum for advice about Java programming isn't going to be particularly helpful.
rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
ok fine....that's what i have been using...but i want to use the same way what is there on the link.....then how can i use it.....actually in my application there is such an requirement that i want to use the techique give on link page.

the link i reffered
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

rammie singh wrote:but i want to use the same way what is there on the link.....then how can i use it.....

Uh, switch to .NET?
Riya Apate
Greenhorn

Joined: Aug 07, 2009
Posts: 2
Do you want this in JSP??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

"Rujuta gl", please check your private messages for an important administrative matter.
rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
yaah i want this in JSp only.....any help??
anila honey
Greenhorn

Joined: Sep 11, 2008
Posts: 7
Hi,

By using hidden variable,you can handle it.


Thanks & Regards,
Anila...
rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
how can we handle it by hidden variable..can you show by a small example please...
and what if there are 7 -8 drop down list on the same page....in that case wil it be a good way to create so many hidden variables.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

I do not see how hidden variables help at all.

Again, all you need to do is to set the selected attribute properly. What's the issue?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to dispaly the selected value of a dropdown list