1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="fr" />
<script type="text/javascript">
<!--
var tabChk = new Array();
function initListChk()
{
//list des input dans la page
//var listInput = document.getElementsByTagName("input");
//list des input dans un conteneur précis
var listInput = document.getElementById("conteneur").getElementsByTagName("input");
var n = listInput.length;
var i, j;
j=0;
for (i=0; i<n; i++)
{
//on ne garde que les checkbox
if (listInput[i].type.toLowerCase()=="checkbox")
{
tabChk[j] = listInput[i];
j++;
}
}
//alert(tabChk.length);
}
function clicAll(obj,x)
{
var exp, n, i, start;
n = tabChk.length;
exp = new RegExp("^"+obj.id,"gi");
switch (x)
{
case 1 :
start=2;
n=7;
break;
case 2 :
start=3;
n=7;
break;
case 3 :
start=4;
n=6;
break;
default :
start=0;
}
for (i=start; i<n; i++)
{
if (exp.test(tabChk[i].id) && obj.id!=tabChk[i].id)
{
tabChk[i].checked = obj.checked;
}
exp.test(""); //Pour Firefox ???
}
decocherCaseTous();
}
function decocherCaseTous()
{
var i, cocher;
cocher = true;
for (i=1; i<tabChk.length; i++)
{
if (!tabChk[i].checked)
{
cocher = false;
}
}
tabChk[0].checked = cocher;
}
//-->
</script>
</head>
<body onload="initListChk()">
<div id="conteneur">
<input type="checkbox" id="idchk2" onclick="clicAll(this,0)" />Tous les choix<br />
<input style="margin-left:10px" type="checkbox" id="idchk2.1" onclick="clicAll(this,1)" />Choix 1 (comprend 2, 3, 4 ,5, 6)<br />
<input style="margin-left:20px" type="checkbox" id="idchk2.1.1" onclick="clicAll(this,2)" />Choix 2 (comprend 3, 4 ,5, 6)<br />
<input style="margin-left:30px" type="checkbox" id="idchk2.1.1.1" onclick="clicAll(this,3)" />Choix 3 (comprend 4 ,5)<br />
<input style="margin-left:30px" type="checkbox" id="idchk2.1.1.1.1" onclick="decocherCaseTous()" />Choix 4<br />
<input style="margin-left:30px" type="checkbox" id="idchk2.1.1.1.2" onclick="decocherCaseTous()" />Choix 5<br />
<input style="margin-left:30px" type="checkbox" id="idchk2.1.1.1.3" onclick="decocherCaseTous()" />Choix 6<br />
<input type="checkbox" id="idchk2.1.1.2" onclick="decocherCaseTous()" />Choix 7<br />
</div>
</body>
</html> |
Partager