Bonjour,
Dans un formulaire, j'ai quatres listes dont les trois dernières sont cachées.
J'aimerais afficher les trois listes avec une création dynamique de la quatrième liste et cela, selon le choix sélectionner dans la premiere liste.
Voila ce que j'ai pu bricoler :
Merci.[/i]
Dans un formulaire, j'ai quatres listes dont les trois dernières sont cachées.
J'aimerais afficher les trois listes avec une création dynamique de la quatrième liste et cela, selon le choix sélectionner dans la premiere liste.
Voila ce que j'ai pu bricoler :
<!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>
<body>
<div id="global">
<div id="liste">
<table class="tbl" style="width: 98%">
<tbody>
<tr>
<td class="titre">Lister les intervenants</td>
</tr>
<tr>
<td>
<form name=gie" action="" method="post">
<div id="list1">
<span class="etq">Lister les intervenants</span>
<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>
</div>
<div id="liste2" style="display:none;">
<span class="etq">Trié par</span>
<select id="liste_2" name="list_2">
<option selected="selected" value="nomint">Nom</option>
<option value="numagr">Numéro agr.</option>
</select>
</div>
<div id="liste3" style="display:none;">
<span class="etq">Sigle</span>
<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></div>
<div id="liste4" style="display:none;">
<span class="etq">Ecole</span>
<select id="liste_4" name="liste_4">
<option>Indifferent</option>
</select>
</div>
<div id="submt" style="display:none;">
<span class="etq"></span>
<input class="bouton" name="B1" style="border: solid; float: right; background-color: #FF0000; font-size: x-small;" type="submit" value="OK" />
</div>
</form>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
Merci.[/i]