Select Options Determined By Another Select’s Selection
Examples
Input Name

HTML

    $(document).ready(function() {
        $('#primaryGoal').change(function() {
            // Remove the selected option from the child
            $("option[value='" + $(this).val() + "']",$('#stGoal')).remove();
            // Now loop through all primary to add previous removed option
            var prevValue = "";
            $("option",$(this)).each(function() {
                // Only add not selected options
                if ($(this).is(":selected") == false) {
                    // Check if the current primary option is not in the child list and it is not the empty select goal option
                    if ($("option[value='" + $(this).val() + "']",$('#stGoal')).length == 0 && $(this).val().length > 0) {
                        if (prevValue == "") {
                            $("option[value='2']",$('#stGoal')).before($('<option>', {
                                value: $(this).val(),
                                text: $(this).text()
                            }));
                        } else {
                            $("option[value='" + prevValue + "']",$('#stGoal')).after($('<option>', {
                                value: $(this).val(),
                                text: $(this).text()
                            }));
                        }
                    }
                }
                prevValue = $(this).val();
            });
            // Rebuild the multi select
            $('#stGoal').multiselect('rebuild');
        });
        $('#stGoal').multiselect({
            nonSelectedText: 'Select Goal',
            buttonWidth: '100%',
            onChange: function(option, checked) {
                // Get selected options.
                var selectedOptions = $('#stGoal option:selected');

                if (selectedOptions.length >= 2) {
                    // Disable all other checkboxes.
                    var nonSelectedOptions = $('#stGoal option').filter(function() {
                        return !$(this).is(':selected');
                    });

                    var dropdown = $('#stGoal').siblings('.multiselect-container');
                    nonSelectedOptions.each(function() {
                        var input = $('input[value="' + $(this).val() + '"]');
                        input.prop('disabled', true);
                        input.parent('li').addClass('disabled');
                    });
                }
                else {
                    // Enable all checkboxes.
                    var dropdown = $('#stGoal').siblings('.multiselect-container');
                    $('#stGoal option').each(function() {
                        var input = $('input[value="' + $(this).val() + '"]');
                        input.prop('disabled', false);
                        input.parent('li').addClass('disabled');
                    });
                }
            }
        });
    });            

jQuery

    $(document).ready(function() {
        $('#primaryGoal').change(function() {
            // Remove the selected option from the child
            $("option[value='" + $(this).val() + "']",$('#stGoal')).remove();
            // Now loop through all primary to add previous removed option
            var prevValue = "";
            $("option",$(this)).each(function() {
                // Only add not selected options
                if ($(this).is(":selected") == false) {
                    // Check if the current primary option is not in the child list and it is not the empty select goal option
                    if ($("option[value='" + $(this).val() + "']",$('#stGoal')).length == 0 && $(this).val().length > 0) {
                        if (prevValue == "") {
                            $("option[value='2']",$('#stGoal')).before($('<option>', {
                                value: $(this).val(),
                                text: $(this).text()
                            }));
                        } else {
                            $("option[value='" + prevValue + "']",$('#stGoal')).after($('<option>', {
                                value: $(this).val(),
                                text: $(this).text()
                            }));
                        }
                    }
                }
                prevValue = $(this).val();
            });
            // Rebuild the multi select
            $('#stGoal').multiselect('rebuild');
        });
        $('#stGoal').multiselect({
            nonSelectedText: 'Select Goal',
            buttonWidth: '100%',
            onChange: function(option, checked) {
                // Get selected options.
                var selectedOptions = $('#stGoal option:selected');

                if (selectedOptions.length >= 2) {
                    // Disable all other checkboxes.
                    var nonSelectedOptions = $('#stGoal option').filter(function() {
                        return !$(this).is(':selected');
                    });

                    var dropdown = $('#stGoal').siblings('.multiselect-container');
                    nonSelectedOptions.each(function() {
                        var input = $('input[value="' + $(this).val() + '"]');
                        input.prop('disabled', true);
                        input.parent('li').addClass('disabled');
                    });
                }
                else {
                    // Enable all checkboxes.
                    var dropdown = $('#stGoal').siblings('.multiselect-container');
                    $('#stGoal option').each(function() {
                        var input = $('input[value="' + $(this).val() + '"]');
                        input.prop('disabled', false);
                        input.parent('li').addClass('disabled');
                    });
                }
            }
        });
    });