You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stefan Faist <st...@hmi-informatik.de> on 2001/08/06 13:09:48 UTC
html:select and html:options
Hello all,
I these two lists:
<td>
<bean:define name="erfassungForm" id="names" property="allProjektNamen" />
<html:select property="projektname">
<html:options collection="names" property="value" labelProperty="label" />
</html:select>
</td>
<td>
<bean:define name="erfassungForm" id="aktivitaeten"
property="allProjekt_aktivitaeten" />
<html:select property="aktivitaetname">
<html:options collection="aktivitaeten" property="value"
labelProperty="label" />
</html:select>
</td>
I want this:
When I select one element in the list <... id="names" ...> the then the list
<... id="aktivitaeten" ...> get elements, that are the activities from the
element of the first list. Is there a way to call a action when I select a
element?
I hope you understand what I want.
Is there any way to do this?
Can someone help me?
Best regards,
STEFAN
----------------------------------------------
hmi-Informatik GmbH
Zettachring 6 - D-70567 Stuttgart
E-Mail: stefan.faist@hmi-informatik.de
http://www.hmi-informatik.de
Re: html:select and html:options
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Mon, 6 Aug 2001, Stefan Faist wrote:
> Hello all,
> I these two lists:
> <td>
> <bean:define name="erfassungForm" id="names" property="allProjektNamen" />
> <html:select property="projektname">
> <html:options collection="names" property="value" labelProperty="label" />
> </html:select>
> </td>
> <td>
> <bean:define name="erfassungForm" id="aktivitaeten"
> property="allProjekt_aktivitaeten" />
> <html:select property="aktivitaetname">
> <html:options collection="aktivitaeten" property="value"
> labelProperty="label" />
> </html:select>
> </td>
>
> I want this:
> When I select one element in the list <... id="names" ...> the then the list
> <... id="aktivitaeten" ...> get elements, that are the activities from the
> element of the first list. Is there a way to call a action when I select a
> element?
> I hope you understand what I want.
>
There are two possible scenarios, depending on how big the various lists
of options for the second select box is.
* You can use Javascript to detect changes in the first select box,
and dynamically change the contents of the second box. This requires
that the various choices for the second box are small enough to have
been included in the page -- perhaps as Javascript arrays of strings.
* You can use Javascript to detect changes in the first select box,
and then submit the form for you. You'll need to tell the Action that
receives the form that this is *only* being submitted to repopulate
the second select box -- perhaps by setting the value of a particular
hidden variable in the form -- so that it will just redisplay the form
with the updated values.
None of this is really particular to Struts -- we're stuck with the
capabilities of HTTP and HTML that we are running on top of.
> Is there any way to do this?
> Can someone help me?
>
> Best regards,
> STEFAN
>
Craig McClanahan