Skip to main content
changed `live` to `on` and `$val.length > 1` to `$val !== '0'`
Source Link

I could be wrong, but I think you could shorten ALOT of the code as follows:

$(function () {
    $(".social-option select").liveon("change", function(e) {
        $(".social-option select option:disabled").prop("disabled", false);
        $(".social-option select option:selected").each(function(i) {
            var $val = $(this).val();
            if ($val.length >!== 1'0') { // is not option 0
                $(".social-option select option[value="+$val+"]").prop("disabled", true);
            };
        });
    }).change();
})​;

See fiddle with dynamic drop down

added here

I could be wrong, but I think you could shorten ALOT of the code as follows:

$(function () {
    $(".social-option select").live("change", function(e) {
        $(".social-option select option:disabled").prop("disabled", false);
        $(".social-option select option:selected").each(function(i) {
            var $val = $(this).val();
            if ($val.length > 1) { // is not option 0
                $(".social-option select option[value="+$val+"]").prop("disabled", true);
            };
        });
    }).change();
})​;

See fiddle with dynamic drop down

added here

I could be wrong, but I think you could shorten ALOT of the code as follows:

$(function () {
    $(".social-option select").on("change", function(e) {
        $(".social-option select option:disabled").prop("disabled", false);
        $(".social-option select option:selected").each(function(i) {
            var $val = $(this).val();
            if ($val !== '0') {
                $(".social-option select option[value="+$val+"]").prop("disabled", true);
            };
        });
    }).change();
})​;

See fiddle with dynamic drop down

added here

added 107 characters in body
Source Link
user10934
user10934

I could be wrong, but I think you could shorten ALOT of the code as follows:

$(function () {
    $(".social-option select").live("change", function(e) {
        $(".social-option select option:disabled").prop("disabled", false);
        $(".social-option select option:selected").each(function(i) {
            var $val = $(this).val();
            if ($val.length > 1) { // is not option 0
                $(".social-option select option[value="+$val+"]").prop("disabled", true);
            };
        });
    }).change();
})​;

See fiddle with dynamic drop down

added here

I could be wrong, but I think you could shorten ALOT of the code as follows:

$(function () {
    $(".social-option select").live("change", function(e) {
        $(".social-option select option:disabled").prop("disabled", false);
        $(".social-option select option:selected").each(function(i) {
            var $val = $(this).val();
            if ($val.length > 1) { // is not option 0
                $(".social-option select option[value="+$val+"]").prop("disabled", true);
            };
        });
    }).change();
})​;

I could be wrong, but I think you could shorten ALOT of the code as follows:

$(function () {
    $(".social-option select").live("change", function(e) {
        $(".social-option select option:disabled").prop("disabled", false);
        $(".social-option select option:selected").each(function(i) {
            var $val = $(this).val();
            if ($val.length > 1) { // is not option 0
                $(".social-option select option[value="+$val+"]").prop("disabled", true);
            };
        });
    }).change();
})​;

See fiddle with dynamic drop down

added here

Source Link
user10934
user10934

I could be wrong, but I think you could shorten ALOT of the code as follows:

$(function () {
    $(".social-option select").live("change", function(e) {
        $(".social-option select option:disabled").prop("disabled", false);
        $(".social-option select option:selected").each(function(i) {
            var $val = $(this).val();
            if ($val.length > 1) { // is not option 0
                $(".social-option select option[value="+$val+"]").prop("disabled", true);
            };
        });
    }).change();
})​;