0

I need to uncheck a dynamically created checkbox. When the checkbox is clicked I need to see whether the value is already present in the database or. If present, then I want to uncheck the checkbox. I tried different ways, but nothing is working.

$(document).on('change', '.subareachk', function() {
  var id = $(this).val();
  $.ajax({
    url: '{!! url('validatesubarea') !!}',
    type: 'get',
    data: {
      'id': id,
    },
    dataType: 'json',
    success: function(data) {
      if (data.length > 0) {
        alert('Already a Store has been assigned for this sub area');
        $(this).prop('checked', false);
      }
    },
  });
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
matheen ulla
  • 526
  • 7
  • 27

0 Answers0