wood burning stoves 2.0*
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
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: 9291

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 ?
Similar Threads
Displaying Data From Different Tables in .jsp
How to select a value in the drop down list with value getting from database?
enable/disable drop down
Tooltip on html:select
Using SELECTED in an html:option tag