How do you call a controller method from an onchange event?
I'm using Spring MVC.
I have a <form:list>
and I wish to update the current page when an onchange event is triggered in the list.
How do you call a controller method from an onchange event?
I'm using Spring MVC.
I have a <form:list>
and I wish to update the current page when an onchange event is triggered in the list.
Just submit the form to the server. You can use the inherited form.submit()
function in JS for this.
onchange="submit()"
In the server side you can do your conditional thing based on the submitted input values.
As a modern alternative, you can also do this totally transparently by firing an asynchronous HTTP request using JS (also known as Ajax). But since you're using Spring MVC and I don't do Spring MVC, I can't suggest how to properly glue Ajax with Spring MVC. You can at least find some articles at Google, for example this one.