javascript - Check only one checkbox in ionic -
javascript - Check only one checkbox in ionic -
in form have 2 checkboxes.but can check both checkboxes.how can disable other checkbox if 1 checkbox checked.
this how gave checkboxes
<label><h4><b>payment type</b></h4></label> <ion-checkbox id="ischecked1" name="ischecked1" ng-model="ischecked1">immediate payment</ion-checkbox> <ion-checkbox id="ischecked2" name="ischecked2" ng-model="ischecked2">schedule payment</ion-checkbox>
i'm not getting why you're not using radio button, here pretty easy illustration using javascript.
working fiddle:
http://jsfiddle.net/qgqto6t7/
html:
<input type="checkbox" id="ischecked1">immediatly</input> <input type="checkbox" id="ischecked2">later</input>
javascript:
var chk1 = document.getelementbyid("ischecked1"); var chk2 = document.getelementbyid("ischecked2"); chk1.onchange = function() { chk1.checked ? chk2.disabled = true : chk2.disabled = false; }; chk2.onchange = function() { chk2.checked ? chk1.disabled = true : chk1.disabled = false; };
however, please take in consideration using radio buttons such task. i'm pretty sure invented reason :)
also, illustration in pure javascript because i'm not familiar angularjs or whatever you're using. in case, should able accomplish using javascript without affecting scripts much.
edit:: moreover, according ids, script should working you, regardless angularjs or not
javascript angularjs checkbox ionic-framework
Comments
Post a Comment