You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sonam Belbase <So...@morganstanley.com> on 2004/07/01 22:31:10 UTC

I have the following:

<!--drop down of names -->
Please select a name:
<html:select property="Name">
    <html:options collection="AvailableNamesList" property="name" />
</html:select>

<!-- corresponding id -->
Your Id will be :
<html:text value="" property="Id" readonly="true" />

The collection AvailableNamesList contains objects that have two fields
- name and id. When
a user selects a name from the dropdown,  its corresponding id should be
displayed in the
<html:text> box.

How do I get it to look at the object in the AvailableNamesList whose
name was selected, retrieve
the id and populate the id property dynamically? I want to avoid a <% %>
section with
java code that iterates over the list and finds the object by looking at
the name. Is this possible?
If so, how?

Thanks,
SB

--
NOTICE: If received in error, please destroy and notify sender.  Sender
does not waive confidentiality or privilege, and use is prohibited.



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


Re:

Posted by Bill Siggelkow <bi...@bellsouth.net>.
If the <html:text value="" property="Id" readonly="true" /> field is on 
the same form as the <html:select> then the only way to populate is to 
use JavaScript. You can do this using an onchange listener on the 
html:select control.  This is not a Struts thing but a JavaScript thing.


Sonam Belbase wrote:
> I have the following:
> 
> <!--drop down of names -->
> Please select a name:
> <html:select property="Name">
>     <html:options collection="AvailableNamesList" property="name" />
> </html:select>
> 
> <!-- corresponding id -->
> Your Id will be :
> <html:text value="" property="Id" readonly="true" />
> 
> The collection AvailableNamesList contains objects that have two fields
> - name and id. When
> a user selects a name from the dropdown,  its corresponding id should be
> displayed in the
> <html:text> box.
> 
> How do I get it to look at the object in the AvailableNamesList whose
> name was selected, retrieve
> the id and populate the id property dynamically? I want to avoid a <% %>
> section with
> java code that iterates over the list and finds the object by looking at
> the name. Is this possible?
> If so, how?
> 
> Thanks,
> SB
> 
> --
> NOTICE: If received in error, please destroy and notify sender.  Sender
> does not waive confidentiality or privilege, and use is prohibited.


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