Loading a jquery function on form submit instead on change event
<p>I have a jQuery script that dynamically changes <code>select</code> menus. The script uses the function <code>populate()</code> everytime a change event occurs in one of the menus. I would like the same script to run after a <code>form</code> submit. To have an idea this is what the script looks like...  </p>

<pre><code>$(document).ready(function(){
    function getUrlVars() {
        var vars = {};
        var parts = window.location.href.replace(/[?&amp;]+([^=&amp;]+)=([^&amp;]*)/gi, function(m,key,value) {
            vars[key] = value;
        });
        return vars;
    }

    function populate() {
        if ($('#STATEID').val() == 'AK' || $('#OB_USTATEID').val() == 'DC') {
            // Alaska and District Columbia have no counties
            $('#county_drop_down3').hide();
            $('#no_county_drop_down3').show();
        } 
        else {
            fetch.doPost('../../getCounties2c.php');
        }
    }

    $('#STATEID').change(populate);

    var fetch = function() {
        var counties = $('#countyid');
        return {
            doPost: function(src) {
                $('#loading_county_drop_down3').show(); // Show the Loading...
                $('#county_drop_down3').hide(); // Hide the drop down
                $('#no_county_drop_down3').hide(); // Hide the "no counties" message (if it's the case)

                if (src) 
                    $.post(src, { state_code3: $('#STATEID').val() },  this.getCounties);
                else 
                    throw new Error('No SRC was passed to getCounties!');
            },
            getCounties: function(results) {
                if (!results) 
                    return;

                var allCities = $("&lt;option value=\"All\"&gt;All Counties&lt;/option&gt;");
                counties.html(results);
                counties.prepend(allCities);
                var first = getUrlVars()["countyid"];
                if (first) { 
                    counties.val(first).attr('selected',true);
                }
                else {
                    counties.val("All").attr('selected',true);
                }

                $('#loading_county_drop_down3').hide(); // Hide the Loading...
                $('#county_drop_down3').show(); // Show the drop down
            }
        }
    }();

    populate();
}); 
</code></pre>

<p>How can I accomplish that? Any suggestions will be highly appreciated!  </p>
