var str = "001101";
var res = str.substring(0, 2);
var res1 = str.substring(2, 4);
var res2 = str.substring(4, 6);
alert(res);
alert(res1);
alert(res2);
if (res == "11") {
document.getElementById("11").checked = true;
} else if (res == "00") {
document.getElementById("11").disabled = true;
}
<legend>Information</legend>
<div class="row">
<div class="col-xs-12 col-sm-3 col-md-3">
<label><strong>{{$val}}</strong>
</label>
</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<input type="checkbox" name="operator" id="11">
</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<input type="checkbox" name="operator" id="12">
</div>
<div class="col-xs-12 col-sm-3 col-md-3">
<input type="checkbox" name="operator" id="23">
</div>
</div>
<br/>
i want to pass variable into id attribute of checkbox so that id for checkbox becomes dynamic..Can any one help me how to achieve it.
Aucun commentaire:
Enregistrer un commentaire