Post a Select Form On Change With Jquery

Posting a select form On Change With Jquery

With this example, you will see how you can post a form when you change a value from a drop down select element.

Jquery Code

The code below can be translated to mean the following. When the 'myclass' class is changed from a user selecting a different option, that form is automatically submitted.

<script type="text/javascript">

    $(document).ready(function () {
        $('.myclass').change(function () {
            $(this).closest('form').trigger('submit');
        });
    });
</script>

HTML Select Element

WThe select element has a class called 'myclass' and its name attribute is my_item.

 <select class="myclass" name="my_item">      
    <option value="all">All</option>     
    <option value="1">One</option>     
    <option value="2">Two</option>  
</select>