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 {}
});
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.
Comments