jQuery: submit form after a value is selected from dropdown

Omu picture Omu · Sep 29, 2010 · Viewed 65.7k times · Source

I have this form in my HTML:

<form action="/awe/ChangeTheme/Change" method="post">

    <select id="themes" name="themes">
        ...
        <option value="blitzer">blitzer</option>
    </select>

    <input type="submit" value="change" />

</form>

Anybody knows how to submit it when a value is selected in the 'themes' dropdown?

Answer

RoToRa picture RoToRa · Sep 29, 2010

The other solutions will submit all forms on the page, if there should be any. Better would be:

$(function() {
    $('#themes').change(function() {
        this.form.submit();
    });
});