lundi 2 décembre 2019

How to disable a selected option if is selected already with a same name input fields?

Currently i am working in my website http://openacessjournal.com One think is that first input field is static after that second and third input fields is created by jquery, When i am trying to using onchange function, the function is working for only first static input fields, not for all. Please help me My code is ` $(document).ready(function () { $("select[name='author_number[]']").each(function () { $(this).change(function () {

        alert($(this).val());

        var selected = $("option:selected", $(this)).val();
        var thisID = $(this).prop("id");            
        $("select[name='author_number[]'] option").each(function() {
        $(this).prop("disabled", false);
        });

        $("select[name='author_number[]']").each(function(){
        if($(this).prop("id") == thisID){
        $("option[value='" + selected + "']", $(this)).prop("disabled", true);
        }
        });

    });
    });
    });`



Aucun commentaire:

Enregistrer un commentaire