dimanche 3 juillet 2016

jquery checking select input if changed with condition

i have this code below when the select changes it works great and check for the correct condition but then for the second time if i change the select both conditions run after each other

$('#x_Statususer').on('change', function () {       
    var chng = !this.options[this.selectedIndex].defaultSelected;
    if (chng) {
        alert("has changed");
        var celm=$( this ).val();
        if (celm== "Revision") {
            $("#btnAction").click(function() {
                var r = confirm("Are you sure you want to set to Revision! ");
                if (r == false) {
                    return false;
                }
            });
        }
        else if (celm == "Canceled") {
            $("#btnAction").click(function() {
                var r = confirm("Are you sure you want to set to Cancel! ");
                if (r == false) {
                    return false;
                }
            });
        }   
    } else {}
});

Aucun commentaire:

Enregistrer un commentaire