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
   |  
<HTML>
<HEAD>
<TITLE>2 Selects dépendants en JavaScript</TITLE>
<script type="text/javascript">
function gensel2() { 
         s2.length=0;
         for ( var n=0; n<list[s1.selectedIndex].length; n=n+2 ) { 
             s2.length++;
             s2.options[s2.length-1].text=list[s1.selectedIndex][n]; 
         } 
}
 
function gensel3() { 
    s3.length=0;
    choix = list[s1.selectedIndex][(s2.selectedIndex*2) + 1];
    for ( var k = 0; k < liste[choix].length; k++ ) { 
        s3.length++;
        s3.options[s3.length-1].text=liste[choix][k]; 
    } 
}
</script>
 
</HEAD>
<BODY>
<form name="frm">
 
<select size=4 name="sel1" id="sel1" onchange="gensel2();">
    <optgroup label="Choisissez votre rubrique">
    <option>Sixième</option>
    <option>Cinquième</option>
    <option>Quatrième</option>
    <option>Troisième</option>
    </optgroup>
</select>
 
<select size=4 name="sel2" id="sel2" onchange="gensel3();">
    <optgroup label="Choisissez votre rubrique">
    </optgroup>
</select>
 
 
<select size=4 name="sel3" id="sel3">
    <optgroup label="Choisissez votre rubrique">
    </optgroup>
</select>
 
 
</form>
<script type="text/javascript">
var s1=document.getElementById("sel1");
var s2=document.getElementById("sel2"); 
var s3=document.getElementById("sel3"); 
 
var list=new Array(
    new Array("Numérique",5,"Géométrie",6),
    new Array("Numérique2",2,"Géométrie2",7),
    new Array("Numérique3",0,"Géométrie3",1, "latitude2",2, "longitude3",3),
    new Array("Numérique4",7,"Géométrie4",8)
);
 
var liste=new Array(
    new Array("..."),
    new Array("...."),
    new Array("non","Finistère","Ille-et-Vilaine","Morbihan"),
    new Array ("Priorités opératoires","Fractions","proportionnalité","Calcul littéral","Nombres relatifs","Statistiques"),
    new Array("à venir "),
    new Array("nombres relatifs","Fractions","Puissances","calul littéral","Equations","Proportionnalité"),
    new Array("but"),
    new Array("rien"),
    new Array("rien2")
);
</script>
 
 
</BODY></HTML> |