mardi 3 mars 2015

Checkbox treeview functionality is not working

This is below code is not working as expected. I mean, on this treeview, when I press the last 4 checkboxs, then, the first checkbox should be checked automatically. Whenever the sublevel checkbox['checkboxG2'] count comes to 4, then, the first level['checkboxG1'] should be selected automatically. Any help please?



<html>
<head></head>
<body>
<div id="BuCheck" class="BusinessCont">
<p><input type="checkbox" name="checkboxG1" id="checkbox1" class="form-checkbox" value="Trauva"/><label for="checkbox1" class="form-label">Trauva</label></p>
<p>&#x00A0;&#x00A0;&#x00A0;<input type="checkbox" name="checkboxG2" id="checkbox2" class="form-checkbox" value="Nitro"/><label for="checkbox2" class="form-label">Nitro</label></p>
<p>&#x00A0;&#x00A0;&#x00A0;<input type="checkbox" name="checkboxG2" id="checkbox3" class="form-checkbox" value="Global Market"/><label for="checkbox3" class="form-label">Global Market</label></p>
<p>&#x00A0;&#x00A0;&#x00A0;<input type="checkbox" name="checkboxG2" id="checkbox4" class="form-checkbox" value="Government Services"/><label for="checkbox4" class="form-label">Government Services</label></p>
<p>&#x00A0;&#x00A0;&#x00A0;<input type="checkbox" name="checkboxG2" id="checkbox5" class="form-checkbox" value="PHASIZE"/><label for="checkbox5" class="form-label">PHASIZE</label></p>
</div>
<script src="http://ift.tt/1mWWrGH"></script>
<script type="text/javascript">
var checkBoxBusiness = function(){
console.log("Checkbox button clickes");
var myChekall = $("#BuCheck input[name=checkboxG2]"), myChecksin = $("#BuCheck input[name=checkboxG1]")[0], myCheckedAll=$("#BuCheck input[name=checkboxG2]:checked");
console.log(myCheckedAll.length);
if(myChekall.length == myCheckedAll.length) {
$(myChecksin).attr("checked", "true");
}
}
checkBoxBusiness();
</script>
</body>
</html>




Aucun commentaire:

Enregistrer un commentaire