jQuery if/else if statement doesn't work after the first "if"
<p>I have a simple jQuery if/else if condition but only the "if" part works, the "else if"  do not, I can't figure out why. The code represents three listboxes (<strong>ajax-populated</strong>) and when any of them clicked, a jQuery function collects the ID of the clicked item and assigns it to a variable. The first one (even when I switch places I get the correct ID number) is fine, never the second or the third. It is not working when I use three "if's" instead of "if/else if" structure either.</p>

<pre><code>$(document).ready(function() {
    $('#btn_edit_details').click(function() {
        var request_id;
        if ($('#lstbx_new_repeat_requests').val().length &gt; 0) {
            request_id = $('#lstbx_new_repeat_requests').val();
            alert(request_id);
        }
        else if ($('#lstbx_approved_repeat_requests').val().length &gt; 0) {
            request_id = $('#lstbx_approved_repeat_requests').val();
            alert(request_id);
        }
        else if ($('#lstbx_declined_repeat_requests').val().length &gt; 0) {
            request_id = $('#lstbx_declined_repeat_requests').val();
            alert(request_id);
        }
if ($('#btn_edit_details').val() == 'edit') {
// rest of the code, working fine when the request_id is passed from the first "if"
</code></pre>

<p>And the HTML</p>

<pre><code>&lt;input type='button' id='btn_edit_details' value='edit' /&gt;
&lt;select id='lstbx_new_repeat_requests' name='lstbx_new_repeat_requests'&gt;&lt;/select&gt;
&lt;select id='lstbx_approved_repeat_requests' name='lstbx_approved_repeat_requests'&gt;&lt;/select&gt;
&lt;select id='lstbx_declined_repeat_requests' name='lstbx_declined_repeat_requests'&gt;&lt;/select&gt;
</code></pre>
