88
rated 0 times
[
90]
[
2]
/ answers: 1 / hits: 52877
/ 11 Years ago, mon, july 29, 2013, 12:00:00
I have many server input checkboxes. I have given the first checkbox the id all
. By default it will be checked. When the user checks other checkboxes, then checkbox with id all
will be unchecked. And if all
is checked other checkboxes will be unchecked. For this to happen i made the code but nothing is happening.
Here is what i have tried.
<form>
<input type=checkbox id=all value=all name=all onChange=check() checked/>ALL <br/>
<input type=checkbox id=servers value=xampp name=server[] onChange=check() />XAMPP <br/>
<input type=checkbox id=servers value=wamp name=server[] onChange=check() />WAMP <br/>
<input type=checkbox id=servers value=mamp name=server[] onChange=check() />MAMP <br/>
<input type=checkbox id=servers value=amp name=server[] onChange=check() />AMP <br/>
</form>
function check(){
var all = document.getElementById(all),
group = document.getElementById(servers);
if(all.checked == true){
group.checked == false;
}elseif(group.checked == true){
all.checked == false;
}
}
I wanted my code to work like THIS.
I dont want to use jQuery for some reasons. So i need my code to be in pure JS.
Any help will be appreciated.
More From » checkbox