简体   繁体   中英

JSP drop down list to select first option by default on page load using struts

Hope someone can help me out on this.

I've got the following drop down list in JSP:

<html:select styleId="facilityId" property="facilityId">
<html:options collection="<%=Session.CONSUMER_FACILITY%>"
property="id" labelProperty="facilityDescription"
/> 
</html:select>

That gets a collection of list to be displayed in the drop down from the Java class perfectly.

But now when I open the page where it shows the drop down list, how can I make the first option selected by default on page load, without clicking and selecting a option?

Can I do something inside that JSP code or some Javascript that can do that?

I'm using Struts.

Hope this makes sense what i'm looking for.

Set facilityId value to expected default during ActionForm initialization.

Guess you're using Struts 1.x

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM