Search code examples
htmljsp

How to submit form on change of dropdown list?


I am creating a page in JSP where I have a dropdown list and once the user selects a value he has to click on the go button and then the value is sent to the Servlet.

            </select>
            <input type="submit" name="GO" value="Go"/>

How do I make it so that it does it on change? E.g. when the user selects John all his details are retrived from the DB and displayed. I want the system to do it without having to click the go button.


Solution

  • Just ask assistance of JavaScript.

    <select onchange="this.form.submit()">
        ...
    </select>
    

    See also: