aspose file tools*
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
Author

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 ..


Thanks,
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
http://www.brainbench.com/transcript.jsp?pid=8192792
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9322
    
  17

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


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to preselect a value in drop down ?