I would like to submit a form to an action on select box change (when an item is selected I need to update another select box and maybe other fields). The following code will submit the form to the controller/action defined on form element.
<g:select onchange="submit()"/>
How could I submit the form to a custom action ? I think to put a hidden action submit on the page and trigger a click on it when selecting an item in the select box, but hopping there is a more elegant way. The project use jquery, so the prototype library isn't available. Thanks a lot !
It is an unusal use-case to submit the whole form, just because one combo box is changed. Usually the following is sufficient submitting only the new value of the combo box.
<g:form id="thisForm" action="yourFormAction">
<g:select
onchange="${remoteFunction(
action:'yourOnChangeAction',
update:'thisForm',
params:'\'thisInputField=\' + this.value' )}"
value="${value}"
name="productDependencyType"
from="${values}" />
</g:form>
However, if your REALLY want to have all other form fields to be submitted as well, I guess it would be the best, to have one dispatching action and your input box sets some hidden field before submitting to the standard form-action. Hidden submit buttons are scary :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With