I have this code:
<g:form controller="IMI" action="action1">
<g:textField name="area" value="${myValue}" />
<br><br>
<div id="address"></div>
<g:submitButton name="update" value="Calcule IMI" />
The introduced text in the textview is accessible in controller via:
params.area
However, i have a js function that will fill my ‘address’ div with text. I would like to retrieve that text in the controller also.
Question:How can i have access in the controller to the text inside div “address” ?
The controller doesn’t have any access to the page itself. If you need to send the contents of the address div back to the controller upon form submission, you could duplicate the contents of it in a hidden input field, like such:
And have your JS that sets the contents of the address also set the value of hiddenAddress to the same. Another idea is to use something like jQuery to catch the form submission, grab the contents of the div and append it to the form submission (essentially achieving the same thing, just using more JS code)