Specify a JavaScript function as an 'onchange' listener for the first drop-down that submits to an action; passing the selected value from the first drop-down on the query string ... like this:

<html:select property="foo" onchange="setFoo(this.form)"> <html:option value="bar"/>
<html:option value="baz"/>
</html:select>
<script language="JavaScript">
function setFoo(form) {
fooCtl = form.elements["foo"];
form.action = "/SetFoo.do?foo=";
form.action += fooCtl.options[fooCtl.selectedIndex].value;
form.submit();
}
</script>


In the SetFoo action, reset the collection used for the second drop-down based on the received value. Then forward back to the JSP page from the SetFoo action.

-Bill Siggelkow


Riedling, Michael wrote:

hello,

1.)
I want to create two dynamic dropdown lists to select main- and submenus of a navigation in a form. I fill both lists with collections, when the User chooses a value in the first dropdown menu (e.G. Navigation main menu), the site should reload and the related collection of the second dropdown menu (e.g. Navigation submenu) have to appear.


I am not sure how to implement that, maybe its very simple and have nothing in 
common with struts. But i need some help with it please :)

Can i do the reload with something like javascript onKeyPress etc. or are there 
usefull struts functions/patterns for it?


Thx in advance

Michael






PS. Here is the codefragement of the two simple dropdown lists, i have implemented so far:

<html:form action="/new" focus="title">
<tr>
<td><bean:message key="new.page.form.title.label"/>:</td> <td><html:text property="title"/></td>
</tr>
<tr>
<td><bean:message key="new.page.form.rootNodeId.label"/>:</td>
<td><html:select property="rootNodeId">
<html:options collection="rootNodes" property="nodeName" labelProperty="nodeName"/>
</html:select>
</td>
</tr>
<tr>
<td><bean:message key="new.page.form.subNodeId.label"/>:</td>
<td><html:select property="subNodeId">
<html:options collection="nodes" property="nodeName" labelProperty="nodeName"/>
</html:select>
</td>
</tr>


<tr>
        <td></td>
        <td><html:submit>
                        <bean:message key="new.page.form.submit.label"/>
                </html:submit>
<html:reset>
                        <bean:message key="form.reset" />
                </html:reset>
        </td>
</tr>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to