Reputation: 3850
In my project i have a check box that is the basis if the input box is disable. When using the click
event i achieve it correctly but when i get it in database it does not behave correctly but i get the value i am expecting. For example the value is 0
it will display disable false and the disable is false (default) when value is 1
it will display disable true but the input is not disabled here is the code any suggestion is appreciated
On click event
$('#flag').click(function() {
console.log("sumenu change on click");
if ($(this).is(":checked")) {
$('#url').prop('disabled', true);
console.log("check disble true");
} else {
$('#url').prop('disabled', false);
console.log("nocheck disble false");
}
});
Code from ajax success that is getting value and should turn off / turn on input on data load
if (data[i].flag == "0") {
console.log("value is 0 no check disble false");
$('#flag').prop('checked', false);
$('#url').prop('disable', false);
} else {
console.log("value is 1 check disble true");
$('#flag').prop('checked', true);
$('#url').prop('disable', true);
}
Upvotes: 0
Views: 107
Reputation: 25527
There is a syntax error in your code,
it should be , $('#url').prop('disabled', true);
not, $('#url').prop('disable', true);
Upvotes: 1