You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Keith C. Klopfer" <k....@comcast.net> on 2003/12/18 12:12:18 UTC

html:select default value problem

Hi,

I know this has been talked about before, and I'm pretty sure I understand the concept, but I don't know why this is not
working.  The default option for an html:select is not being displayed.  I have an ActionForm in request scope called
"BusinessForm" that is populated.  The "status" property has a value of "1" as verified by sticking in a bean:write, but
the select list shows the value="0" option as the default item when I load the page.  I have twelve other html elements on
the page, and they all show the correct defaults, except for this html:select.  Am I not seeing something in the code
below...

thanks...keith

---

<html:form action="action.do" scope="request" name="BusinessForm" type="BusinessForm">

<!-- to verify the value of the status property (it displays "1") -->
<bean:write name="BusinessForm" property="status" />

<html:select property="status">
    <option value="0">0 - INACTIVE</option>
    <option value="1">1 - ACTIVE</option>
</html:select>

...

</html:form

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: html:select default value problem

Posted by Robert Taylor <rt...@mulework.com>.
Try this:

<html:select property="status">
     <html:option value="0">0 - INACTIVE</html:option>
     <html:option value="1">1 - ACTIVE</html:option>
</html:select>

The regular HTML <option/> element doesn't "communicate" with 
Struts. You need to use <html:option />

robert

> -----Original Message-----
> From: Keith C. Klopfer [mailto:k.klopfer@comcast.net]
> Sent: Thursday, December 18, 2003 6:12 AM
> To: struts-user@jakarta.apache.org
> Subject: html:select default value problem
> 
> 
> Hi,
> 
> I know this has been talked about before, and I'm pretty sure I 
> understand the concept, but I don't know why this is not
> working.  The default option for an html:select is not being 
> displayed.  I have an ActionForm in request scope called
> "BusinessForm" that is populated.  The "status" property has a 
> value of "1" as verified by sticking in a bean:write, but
> the select list shows the value="0" option as the default item 
> when I load the page.  I have twelve other html elements on
> the page, and they all show the correct defaults, except for this 
> html:select.  Am I not seeing something in the code
> below...
> 
> thanks...keith
> 
> ---
> 
> <html:form action="action.do" scope="request" name="BusinessForm" 
> type="BusinessForm">
> 
> <!-- to verify the value of the status property (it displays "1") -->
> <bean:write name="BusinessForm" property="status" />
> 
> <html:select property="status">
>     <option value="0">0 - INACTIVE</option>
>     <option value="1">1 - ACTIVE</option>
> </html:select>
> 
> ...
> 
> </html:form
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org