jquery checking select input if changed with condition

Hemin

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 {}
});
Ismail RBOUH

The problem is that you rebind the click event to #btnAction at each change. Try to change:

$("#btnAction").click(function() {...});

To:

$("#btnAction").one(function() {...});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Checking for 'input' and 'select' jQuery

From Dev

JQuery change input when select changed

From Dev

ngChange on input changed by a select

From Dev

Condition checking in python with user input

From Dev

Checking form input values with jquery

From Dev

jquery checking radio input not working

From Dev

Checking value of an html select with jQuery

From Dev

Checking value of an html select with jQuery

From Dev

jQuery check if select field changed

From Dev

Uncheck box using jQuery after checking condition

From Dev

Uncheck box using jQuery after checking condition

From Dev

Disable Select Box when text input changed

From Dev

Checking if a form has input elements using jQuery

From Dev

checking numbers from input using Jquery

From Dev

Jquery checking the upload filename in file type input

From Dev

Checking focus on input element with jQuery fails

From Dev

Select jquery input

From Dev

JQuery Select Input By Value

From Dev

Cannot select input jquery

From Dev

Javascript Jquery on one of the multiple input fields changed

From Dev

Update Angular ngModel of a Select changed by jQuery

From Dev

AngularJS select model not updating when filter condition changed

From Dev

How to block checkboxes for checking when certain condition is met in jQuery?

From Dev

Detect which input / select was changed and get its value

From Dev

jquery select input field search

From Dev

Programatically checking input via jQuery not calling form's .change() event?

From Dev

Why is my jQuery script for checking required input fields so slow?

From Java

Angular 10 input value binding changed by jquery.val()

From Dev

Input event not working if value is changed with jQuery val() or JavaScript

Related Related

HotTag

Archive