Search code examples
struts-1

Adding another option to <html:select>


State:
<html:select property="product.stateId" size="1" onchange="loadProducts();loadProducts2();">
    <html:options collection="stateList" property="id" labelProperty="name"/>
</html:select>

I want to add another option to the list of states such as, "Please select state," in the drop down menu. I think I need to modify the Java collection object..


Solution

  • Just add a <html:option> tag which represents that. The TLDDOC allows that:

    This tag can be used multiple times within a single <html:select> element, either in conjunction with or instead of one or more <html:option> or <html:optionsCollection> elements.