Javascript: delaying form submission
<p>I have several &lt;select&gt; fields and I want their parent form to submit automatically when their values are changed but I want there to be a delay of 1.5 seconds and abort the submit if the user opens another select.</p>

<p>I tried this:</p>

<pre><code>var tmr;
var timerOn = false;

function submitSearchOptions() {
    $('#searchoptionsform').submit();
}

$('#searchoptionsform select').change(function() {
    if (!timerOn) {
        tmr = setTimeout(submitSearchOptions,1500);
        timerOn = true;
    }
});

$('#searchoptionsform select').click(function() {
    if (timerOn) {
        clearTimeout(tmr);
        timerOn = false;
    }
});
</code></pre>

<p>But it doesn't work. Selecting a value in a select also fires the click event which stops the timer. </p>
