jQuery in Action, 3rd edition
The moose likes Struts and the fly likes How to preselect a value in drop down ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to preselect a value in drop down ?" Watch "How to preselect a value in drop down ?" New topic

How to preselect a value in drop down ?

Rite Sara
Ranch Hand

Joined: Feb 13, 2010
Posts: 56
Hi ..

I am using Struts 1.3 and using following code to display drop down in one tab on my page ..

There is one more such drop down on home page.
If user selects an option on home page and navigates to this tab then the same value should be preselected in this drop down ..

Please let me know how this can be handled ..

Bhagat Singh Rawat
Ranch Hand

Joined: Apr 04, 2009
Posts: 93
write a JavaScript method and call it onload. get options and iterate through them. Set option.selected=true whichever you want.

Brainbench Java 2.0 Fundamentals, J2EE 1.4
Ankit Garg

Joined: Aug 03, 2008
Posts: 9466

You can also use the value attribute of html:select tag to preselect any option...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I agree. Here's the link: http://aspose.com/file-tools
subject: How to preselect a value in drop down ?
It's not a secret anymore!