<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Lister les intervenants</title> <style type="text/css"> body { margin: 0; padding: 0; } #global { position:absolute; left: 50%; top: 50%; width: 700px; height: 400px; margin-top: -200px; margin-left: -350px; border: 1px solid #333; background-color: #eee; } #liste { width: 280px; left: 10%; top: 10%; position: relative; } .titre{ color: #FFF; font-family: Tahoma; font-size: 12px; background-color: #0000FF; text-align: center; } .etq{ font-family: Tahoma; color: #000; font-size: 12px; text-align: left; width: 120px; display: inline-block; } .chp {text-align: left ;} .bouton {float: right ; background:red;} .tbl { border: 1px solid #0000FF;width:98%} </style> <script type="text/javascript" language="javascript"> var liste_4_0 = ["E1","E2","E4"]; var liste_4_1 = ["théâtre","informatique","langue vivante"]; var liste_4_2 = ["Congnac la ville","Bussines","St-Junien"]; var liste_4_3 = ["BELLAC","LIMOGES I","LIMOGES II"]; var liste_4 = [liste_4_0,liste_4_1,liste_4_2,liste_4_3]; function fill_list_choice(next_list, valAAfficher){ //alert("Valeur à afficher : "+valAAfficher); if(valAAfficher === "-1"){ return; } switch(next_list){ case "liste_4" : var liste = liste_4[valAAfficher]; var next_list = document.getElementById(next_list); var opt, child, j=0; // On supprime les éléments qui y sont pour l'instant while(child = next_list.childNodes[0]){ next_list.removeChild(child); } // On créé la liste voulue opt = document.createElement("option"); opt.innerHTML = "Indifferent"; next_list.appendChild(opt); for(var i 0, l liste.length;i<l;i++){ opt = document.createElement("option"); opt.innerHTML = liste[i]; opt.value = i; next_list.appendChild(opt); } break; default: alert("Liste inconnue"); return; } afficherAutres; } function afficherAutres() { var l2 = document.getElementById("liste2"); var l3 = document.getElementById("liste3"); var l4 = document.getElementById("liste4"); var Sb = document.getElementById("submt"); if (document.gie.liste_1.value != "-1") { if (l2.style.display == "none") l2.style.display = "block"; if (l3.style.display == "none") l3.style.display = "block"; if (l4.style.display == "none") l4.style.display = "block"; if (Sb.style.display == "none") Sb.style.display = "block"; } else { l2.style.display = "none"; l3.style.display = "none"; l4.style.display = "none"; Sb.style.display = "none"; } } </script> </head> Lister les intervenants, ---- <form name="gie" action="" method="post"> Lister les intervenants <select id="liste_1" name="liste_1" onchange="fill_list_choice('liste_4', this.value);"> <option value="-1">Selectionner</option> <option value="1">Par Ecole</option> <option value="2">Par Discipline</option> <option value="3">Par Localisation</option> <option value="4">Par Circonscription</option> </select> Trié par <select id="liste_2" name="list_2"> <option selected="selected" value="nomint">Nom</option> <option value="numagr">Numéro agr.</option> </select> Sigle <select id="liste_3" name="liste_3"> <option selected="selected" value="EMC">EMC</option> <option value="EPC">EPC</option> <option value="ECU">ECU</option> </select> Ecole <select id="liste_4" name="liste_4"> <option>Indifferent</option> </select> </form> </html>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question<head> <style type="text/css"> a span { display: none; position: absolute; top: 20px; left: 100px; } a:hover span { display:inline; } </style> </head> [# ]
var liste_4_0 = ["E1","E2","E4"];
var liste_4_1 = ["théâtre","informatique","langue vivante"];
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>2 Selects dépendants en JavaScript</title> <style type="text/css"> select { float:left; } </style> </head> <select size="4" name="sel1" id="sel1"> <optgroup label="Régions"> <option>Bretagne</option> <option>Centre</option> <option>Nord-Pas-de-Calais</option> </optgroup> </select> <select size="4" name="sel2" id="sel2"> <optgroup label="Départements"> <option>?</option> </optgroup> </select> <script type="text/javascript"><!-- var liste=new Array ( new Array ( "Côtes-d'Armor","Finistère","Ille-et-Vilaine","Morbihan" ) , new Array ( "Cher","Eure-et-Loire","Indre","Indre-et-Loire","Loir-et-Cher","Loiret" ) , new Array ( "Nord","Pas-de-Calais" ) ); var s1=document.getElementById("sel1"); var s2=document.getElementById("sel2"); var txt=document.getElementById("txt"); s1.onchange=function() { txt.value=s1.options[s1.selectedIndex].text; s2.length=0; s2.length=liste[s1.selectedIndex].length; for ( var n=0; n < liste[s1.selectedIndex].length; n++ ) { s2.options[n].text=liste[s1.selectedIndex][n]; } s2.size=s2.length+1; } s2.onchange=function() { txt.value= s1.options[s1.selectedIndex].text+" / "+ s2.options[s2.selectedIndex].text; } --></script> </html>