Nieuw lid |
|
hapklare code (wegens bored)
sidenote, je moet valide html hebben, anders worden de cb's in IE pas selected nadat je ergens naast de cb klikte
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function check(parentID, value)
{
var cbs = new Array();
cbs = document.getElementById(parentID).getElementsByTagName('input');
for (var i = 0; i < cbs.length; i++)
{
if (cbs[i].type == 'checkbox')
{
if(value == true)
{
cbs[i].checked = true;
}
else
{
cbs[i].checked = false;
}
}
}
}
</script>
</head>
<body>
<div id="een">
<input name="cb1" type="checkbox" value="1" /><br />
<input name="cb2" type="checkbox" value="1" /><br />
<input name="cb3" type="checkbox" value="1" /><br />
<input name="cb4" type="checkbox" value="1" /><br />
<input name="cb5" type="checkbox" value="1" /><br />
<input name="cb6" type="checkbox" value="1" /><br />
<input name="all" type="checkbox" value="checked" onchange="check('een', this.checked)" />check groep
</div>
<br /><br />
<div id="twee">
<input name="cb1" type="checkbox" value="1" /><br />
<input name="cb2" type="checkbox" value="1" /><br />
<input name="cb3" type="checkbox" value="1" /><br />
<input name="cb4" type="checkbox" value="1" /><br />
<input name="cb5" type="checkbox" value="1" /><br />
<input name="cb6" type="checkbox" value="1" /><br />
<input name="all" type="checkbox" value="checked" onchange="check('twee', this.checked)" />check groep
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> function check(parentID, value) { var cbs = new Array(); cbs = document.getElementById(parentID).getElementsByTagName('input'); for (var i = 0; i < cbs.length; i++) { if (cbs[i].type == 'checkbox') { if(value == true) { cbs[i].checked = true; } else { cbs[i].checked = false; } } } } <input name="cb1" type="checkbox" value="1" /><br /> <input name="cb2" type="checkbox" value="1" /><br /> <input name="cb3" type="checkbox" value="1" /><br /> <input name="cb4" type="checkbox" value="1" /><br /> <input name="cb5" type="checkbox" value="1" /><br /> <input name="cb6" type="checkbox" value="1" /><br /> <input name="all" type="checkbox" value="checked" onchange="check('een', this.checked)" />check groep <input name="cb1" type="checkbox" value="1" /><br /> <input name="cb2" type="checkbox" value="1" /><br /> <input name="cb3" type="checkbox" value="1" /><br /> <input name="cb4" type="checkbox" value="1" /><br /> <input name="cb5" type="checkbox" value="1" /><br /> <input name="cb6" type="checkbox" value="1" /><br /> <input name="all" type="checkbox" value="checked" onchange="check('twee', this.checked)" />check groep
|