lundi 3 juin 2019

How should i set checkbox value to false on single click?

On my edit operation, my check-boxes gets filled according to values stored in database. I am using same form for edit and add operations. Now when I click on edit and unchecked the checkbox, it does not return false on single click, it returns false when i double click (for ex uncheck(returns true) -> check(returns true) -> uncheck(returns false)). I want checkbox to return false on single click when unchecked, if it is brings checked value.

controller.js

 $scope.edit = function (user) {
  if (user.Form1007 == "True") {
            $('#Form1007').attr('checked', true);
        }
        else {
            $('#Form1007').attr('checked', false);
        }
};

form.html

<div class="form-group" style="padding-top: 10px;">
 <label for="inputEmail3" class="col-sm-3 control-label">Form 1007 :</label>
 <div class="col-sm-8">
  <input type="hidden" name="Form1007" value="false" /> 
  <input ng-model="form.Form1007" name="Form1007" type="checkbox"id="Form1007" value="True"/>
    </div>
 </div>
``




Aucun commentaire:

Enregistrer un commentaire