Untitled

 avatar
unknown
plain_text
2 years ago
2.5 kB
4
Indexable
$("select").change(function () {
        let vikas = $(this).first()
        let valuesOfVikasOptions = Array()
        if (vikas.val() == "" || vikas.val() == '--Select--') {
            vikas.find("option").each(function () {
                if ($(this).val() != '--Select--' && $(this).val() != "") {
                    valuesOfVikasOptions.push($(this).val())
                }
            })

            $('select').each(function () {
                if ($(this).val() != '--Select--' && $(this).val() != "") {
                    if (valuesOfVikasOptions.includes($(this).val())) {
                        let toBeRemoved = valuesOfVikasOptions.indexOf($(this).val());
                        if (toBeRemoved > -1) {
                            valuesOfVikasOptions.splice(toBeRemoved, 1);
                        }
                    }
                }

            })
        }
        $("select").each(function () {
            if (vikas[0] == $(this)[0]) {
                vikas.find("option").each(function () {
                    if ($(this).val() != '--Select--' && $(this).val() != "") {
                        valuesOfVikasOptions.push($(this).val())
                    }
                })
                $('select').each(function () {
                    if ($(this).val() != '--Select--' && $(this).val() != "") {
                        if (valuesOfVikasOptions.includes($(this).val())) {
                            let toBeRemoved = valuesOfVikasOptions.indexOf($(this).val());
                            if (toBeRemoved > -1) {
                                valuesOfVikasOptions.splice(toBeRemoved, 1);
                            }
                        }
                    }

                })

            }
            $(this).find('option').each(function () {
                if (valuesOfVikasOptions.includes($(this).val())) {
                    $(this).removeAttr('disabled')
                }
            });
            let option = "option[value='" + vikas.val() + "']"
            if (vikas[0] != $(this)[0]) {
                $(this).find(option).each(function () {
                    if ($(this).val() != '--Select--' && $(this).val() != '' && $(this).val() !=
                        'Others') {
                        $(this).attr('disabled', 'true');
                    } else {
                        $(this).removeAttr('disabled')
                    }
                })
            }
        })
    })
Editor is loading...