Part of jQuery not executing
<p>My issue is as follows:</p>

<p>When I test this, the part marked as NOT BEING EXECUTED is not executed.
The rest of the code prior to that point works fine, but after that line nothing happens.</p>

<p>Am I missing something?  I'm running Firefox with firebug and I can see that the vars (enrolled, groupcontracting and thirdparty) are being defined as 1 or 0.. but they don't see to be visible to the code below the 'NOT BEING EXECUTED' line.</p>

<pre><code>$(document).ready(function () {


    $('#restofform').css('display', 'none');
    $('#pharmdata').css('display', 'none');
    $('#form_bottom').css('display', 'none');
    $('#nextsteps').css('display', 'none');
    $('#group_status_message').css('display', 'none');
    $("#Affiliation").css('display', 'none');
    $("#affiliation_note").css('display', 'none');
    $("#AffiliationLabel").css('display', 'none');
    $("#affilitation").css('display', 'none');

    var enrolled;
    var groupcontracting;
    var thirdparty;

    $('#UserNumber').keyup(function check_enrollment() {

        //get the userid
        var userid = $('#UserNumber').val();
        var input_length = $("#UserNumber").val().length;

        function populate(frm, data) {
            $.each(data, function (key, value) {
                $('[id=' + key + ']', frm).val(value);
            });
        }

        if (input_length &gt;= 7) {
            //network enrollment check
            var enlink = "enrollment_check.php?userid =" + userid;
            var gpclink = "group_contracting_check.php?userid =" + userid;
            var bncdlink = "thirdparty_check.php?userid =" + userid;
            $.getJSON(enlink, function (result) {
                console.log(result);

                if (jQuery.isEmptyObject(result)) {
                    //show that the pharmacy is not enrolled
                    $('#enroll_status').addClass('badge badge-inverse');
                    $('#enroll_status').html('Not Enrolled');
                    enrolled = '0';
                    console.log(enrolled);

                } else if (!jQuery.isEmptyObject(result)) {
                    //show that the pharmacy is enrolled
                    $('#enroll_status').addClass('badge badge-success');
                    $('#enroll_status').html('Enrolled');
                    enrolled = '1';
                    console.log(enrolled);
                }
            });
            // end of network enrollment check  

            // group contracting affiliation check
            $.getJSON(gpclink, function (gcresult) {
                console.log(gcresult);

                if (!jQuery.isEmptyObject(gcresult)) {
                    //show that the username is available
                    $('#group_status').addClass('badge badge-success');
                    $('#group_status').html('Group Affiliated');
                    groupcontracting = '1';
                    console.log(groupcontracting);

                } else if (jQuery.isEmptyObject(gcresult)) {
                    //show that the username is NOT available
                    groupcontracting = '0';
                    console.log(groupcontracting);
                }
            });
            // end of group contracting check

            // third party contractual relationship check
            $.getJSON(bncdlink, function (bdresult) {
                console.log(bdresult);

                if (!jQuery.isEmptyObject(bdresult)) {
                    //show that the username is available
                    $('#thirdparty_status').addClass('badge badge-success');
                    $('#thirdparty_status').html('Third Party');
                    thirdparty = '1';
                    console.log(thirdparty);

                } else if (jQuery.isEmptyObject(bdresult)) {
                    //show that the username is NOT available
                    thirdparty = '0';
                    console.log(thirdparty);
                }
            });
            //end of third party check


            // ***********THIS PART IS NOT BEING EXECUTED *************
            // check to see what the variables are set to and display accordingly

            if ((enrolled == '0') &amp;&amp; (groupcontracting == '0') &amp;&amp; (thirdparty == '0')) {

                // set hidden fields 
                $('input[name=enrolled]').val('0');
                $('input[name=groupcontracting]').val('0');
                $('input[name=thirdparty]').val('0');
                //show and hide appropriate parts of forms
                $('#restofform').css('display', '');
                $('#form_bottom').css('display', '');
                $('#pharmdata').css('display', 'none');
                $('#nextsteps').css('display', '');
                $('#form_continue').attr('disabled', true);
                $('#form_continue').css('display', 'none');
                $('#form_enroll').attr('disabled', false);
                $('#form_enroll').css('display', '');
                // enable form fields
                $('#FirstName').attr('disabled', false);
                $('#LastName').attr('disabled', false);
                $('#EmailAddress').attr('disabled', false);
                $('#HomePhone').attr('disabled', false);
                $('#FaxNumber').attr('disabled', false);
                $('#CompanyName').attr('disabled', false);
                $('#Role').attr('disabled', false);
                $('#Comments').attr('disabled', false);
                //display third party message since the Pharmacy will need to sign with them.
                $('#steps').append('&lt;li&gt;This would be the third party statement, letting the pharmacy know that the third party will be contacting them.&lt;/li&gt;');

            } else if ((enrolled == '0') &amp;&amp; (groupcontracting == '1') &amp;&amp; (thirdparty == '0')) {

                // set hidden fields 
                $('input[name=enrolled]').val('0');
                $('input[name=groupcontracting]').val('1');
                $('input[name=thirdparty]').val('0');
                //show and hide appropriate parts of forms
                $('#restofform').css('display', '');
                $('#form_bottom').css('display', '');
                $('#pharmdata').css('display', 'none');
                $('#nextsteps').css('display', '');
                $('#form_continue').attr('disabled', true);
                $('#form_continue').css('display', 'none');
                $('#form_enroll').attr('disabled', false);
                $('#form_enroll').css('display', '');
                // enable form fields
                $('#FirstName').attr('disabled', false);
                $('#LastName').attr('disabled', false);
                $('#EmailAddress').attr('disabled', false);
                $('#HomePhone').attr('disabled', false);
                $('#FaxNumber').attr('disabled', false);
                $('#CompanyName').attr('disabled', false);
                $('#Role').attr('disabled', false);
                $('#Comments').attr('disabled', false);
                //display third party message since the Pharmacy will need to sign with them.
                $('#steps').append('&lt;li&gt;This would be the third partystatement, letting the pharmacy know that the third party will be contacting them.&lt;/li&gt;');
                // show message to Pharmacy that they can enroll, but their group contracting entity will enroll them in products
                $('#steps').append('&lt;li&gt;As a pharmacy currently affiliated with a group contracting entity, you will be able to enroll in the network, but enrollment in the Preferred Network will be handled by your group contracting entity.&lt;/li&gt;');


            } else if ((enrolled == '0') &amp;&amp; (groupcontracting == '0') &amp;&amp; (thirdparty == '1')) {

                // set hidden fields 
                $('input[name=enrolled]').val('0');
                $('input[name=groupcontracting]').val('0');
                $('input[name=thirdparty]').val('1');
                //show and hide appropriate parts of forms
                $('#restofform').css('display', '');
                $('#form_bottom').css('display', '');
                $('#pharmdata').css('display', 'none');
                $('#nextsteps').css('display', '');
                $('#form_continue').attr('disabled', true);
                $('#form_continue').css('display', 'none');
                $('#form_enroll').attr('disabled', false);
                $('#form_enroll').css('display', '');
                // enable form fields
                $('#FirstName').attr('disabled', false);
                $('#LastName').attr('disabled', false);
                $('#EmailAddress').attr('disabled', false);
                $('#HomePhone').attr('disabled', false);
                $('#FaxNumber').attr('disabled', false);
                $('#CompanyName').attr('disabled', false);
                $('#Role').attr('disabled', false);
                $('#Comments').attr('disabled', false);

            } else if ((enrolled == '1') &amp;&amp; (groupcontracting == '0') &amp;&amp; (thirdparty == '0')) {

                // set hidden fields 
                $('input[name=enrolled]').val('1');
                $('input[name=groupcontracting]').val('0');
                $('input[name=thirdparty]').val('0');
                //show &amp; populate and hide appropriate parts of forms
                $('#restofform').css('display', 'none');
                $('#pharmdata').css('display', '');
                $('#form_bottom').css('display', '');
                $('#nextsteps').css('display', '');
                $('#form_continue').attr('disabled', false);
                $('#form_continue').css('display', '');
                $('#form_enroll').attr('disabled', true);
                $('#form_enroll').css('display', 'none');
                populate('#pharmdata', result); // set as the div the fields are in and NOT the form
                // disable form fields
                $('#FirstName').attr('disabled', true);
                $('#LastName').attr('disabled', true);
                $('#EmailAddress').attr('disabled', true);
                $('#HomePhone').attr('disabled', true);
                $('#FaxNumber').attr('disabled', true);
                $('#CompanyName').attr('disabled', true);
                $('#Role').attr('disabled', true);
                $('#Comments').attr('disabled', true);
                // show message to Pharmacy that they should check their info before proceding
                $('#steps').append('&lt;li&gt;If any of your information needs to be updated, please click &lt;a href="mailto:network@company.com"&gt;here&lt;/a&gt; to email our network support team.&lt;/li&gt;');
                //display third partymessage since the Pharmacy will need to sign with them.
                $('#steps').append('&lt;li&gt;This would be the third party statement, letting the pharmacy know that the third party will be contacting them.&lt;/li&gt;');

            } else if ((enrolled == '1') &amp;&amp; (groupcontracting == '1') &amp;&amp; (thirdparty == '0')) {

                // set hidden fields 
                $('input[name=enrolled]').val('1');
                $('input[name=groupcontracting]').val('1');
                $('input[name=thirdparty]').val('0');
                // show message to Pharmacy that they are good to go and have nothing further to do.
                $('#group_status_message').html('&lt;p class="content-p"&gt;As a pharmacy both currently a Network Member and affiliated with a group contracting entity, no further steps are required. You will be enrolled into the Preferred Network by your group contracting entity.&lt;/p&gt;');

            } else if ((enrolled == '1') &amp;&amp; (groupcontracting == '1') &amp;&amp; (thirdparty == '1')) {

                // set hidden fields 
                $('input[name=enrolled]').val('1');
                $('input[name=groupcontracting]').val('1');
                $('input[name=thirdparty]').val('1');
                // show message to Pharmacy that they are good to go and have nothing further to do.
                $('#group_status_message').html('&lt;p class="content-p"&gt;As a pharmacy both currently a Network Member and affiliated with a group contracting entity, no further steps are required. You will be enrolled into the Preferred Network by your group contracting entity.&lt;/p&gt;');

            } else if ((enrolled == '1') &amp;&amp; (groupcontracting == '0') &amp;&amp; (thirdparty == '1')) {

                // set hidden fields 
                $('input[name=enrolled]').val('1');
                $('input[name=groupcontracting]').val('0');
                $('input[name=thirdparty]').val('1');
                //show &amp; populate and hide appropriate parts of forms
                $('#restofform').css('display', 'none');
                $('#pharmdata').css('display', '');
                $('#form_bottom').css('display', '');
                $('#nextsteps').css('display', '');
                $('#form_continue').attr('disabled', false);
                $('#form_continue').css('display', '');
                $('#form_enroll').attr('disabled', true);
                $('#form_enroll').css('display', 'none');
                populate('#pharmdata', result); // set as the div the fields are in and NOT the form
                // disable form fields
                $('#FirstName').attr('disabled', true);
                $('#LastName').attr('disabled', true);
                $('#EmailAddress').attr('disabled', true);
                $('#HomePhone').attr('disabled', true);
                $('#FaxNumber').attr('disabled', true);
                $('#CompanyName').attr('disabled', true);
                $('#Role').attr('disabled', true);
                $('#Comments').attr('disabled', true);
                // show message to Pharmacy that they should check their info before proceding
                $('#steps').append('&lt;li&gt;If any of your information needs to be updated, please click &lt;a href="mailto:network@company.com"&gt;here&lt;/a&gt; to email our network support team.&lt;/li&gt;');

            }

        }
    });
    // end of 3rd party contract check
    // end of all checks



}); // document.ready()
</code></pre>
