Liste déroulante en relation avec d'autre liste déroulante

Résolu
ManuAntibes Messages postés 491 Date d'inscription mardi 24 octobre 2000 Statut Membre Dernière intervention 18 novembre 2021 - 16 juin 2005 à 14:56
ManuAntibes Messages postés 491 Date d'inscription mardi 24 octobre 2000 Statut Membre Dernière intervention 18 novembre 2021 - 17 juin 2005 à 14:57
Salut
je voudrais faire 3 listes déroulantes.( service, personnel, sujet)
Je souhaite pouvoir afficher des informations differentes dans les listes déroulantes 2 et 3 ( personnel et suject) en fonction du choix de la 1ere liste déroulante(service).

voici mon code qui a plusieurs problemes.
1) Je n'arrive pas a recuperé la valeur de la liste déroulante service dans la variable Groupe (avec mon code elle est vide).

2) Lorsque je choisi un service dans la liste déroulante 1, j'ai que la liste déroulante 2 (personnel) qui se modifie, la liste 3 (sujet) ne bouge pas.
Je souhaite que la liste 3 aussi ce mette a jour?

<html>
<head>
<script language= "JavaScript" type="text/JavaScript">
list_service = new Array();
list_service[1] ="Administratif";
list_service[2] ="Direction";

function modif(){
var Groupe = form1.service.value;
//var Groupe ="Administratif";
var perso=document.form1.personne;
var Suj=document.form1.sujet;
if (Groupe =="Administratif"){
perso.options[1].text="Vero1"
perso.options[2].text="Vero2"
perso.options[3].text="Vero3"
perso.options[4].text="Vero4"
perso.options[5].text="Vero5"}
if (Groupe =="Direction"){
perso.options[1].text="Christophe1"
perso.options[2].text="Christophe2"
perso.options[3].text="Christophe3"
perso.options[4].text="Christophe4"
perso.options[5].text="Christophe5"}
if (Groupe =="Administratif"){
Suj.options[1].text="bl1"
Suj.options[2].text="bl2"
Suj.options[3].text="bl3"
Suj.options[4].text="bl4"
Suj.options[5].text="bl5"}
if (Groupe =="Direction"){
Suj.options[1].text="RDV1"
Suj.options[2].text="RDV2"
Suj.options[3].text="RDV3"
Suj.options[4].text="RDV4"
Suj.options[5].text="RDV5"}
}
</script>
</head>

<form name="form1" method="post" action="">
<select name="service" onChange="modif()">
<option value="0">Choisir un service</option>
<script language="JavaScript" type="text/JavaScript">
for (a=1; a<5; a++){
document.write('<option value="'+a+'">'+list_service[a]+'</option>');
}
</script>
</select>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Personne dans le service :
<select name ="personne" onChange= "modif()">
<script language="JavaScript" type="text/JavaScript">
for (b=1; b<=5; b++){
document.write('<option value="'+b+'">'+ +'</option>');
}
</script>
</select>
Sujet :
<select name ="sujet">
<script language="JavaScript" type="text/JavaScript">
for (c=1; c<=5; c++){
document.write('<option value="'+c+'">'+ +'</option>');
}
</script>
</select>
</form>

</html>

A+
MANUANTIBES

5 réponses

hippyz Messages postés 56 Date d'inscription vendredi 21 mai 2004 Statut Membre Dernière intervention 7 mai 2006
16 juin 2005 à 16:29
En fait j'avais postée une source il y a peu de temps qui aurait pu t'aider d'aprés moi.

Aprés quelque modif voici une fonction qui fonctionne trés bien, regarde donc si c'est ce que tu voulais.



function trierMenu(form,list,list1,variable)

{





list.options.length=0;

list1.options.length=0;

if (variable == "administration")

{




for(i=1;i <= 5; i++)

{

choix=new Option("Vero"+[i],"Vero"+[i]);

form.perso.options[form.perso.options.length]=choix;



choix=new Option("bl"+[i],"bl"+[i]);


form.sujet.options[form.sujet.options.length]=choix;




}

}

else if (variable == "direction")

{

for(i=1;i <= 5; i++)

{

choix=new Option("Christophe"+[i],"Christophe"+[i]);

form.perso.options[form.perso.options.length]=choix;



choix=new Option("RDV"+[i],"RDV"+[i]);

form.sujet.options[form.sujet.options.length]=choix;

}

}

}
3
hippyz Messages postés 56 Date d'inscription vendredi 21 mai 2004 Statut Membre Dernière intervention 7 mai 2006
16 juin 2005 à 16:33
Ah oui n'oubles pas de modifier le nom de formulaire etc.............
0
ManuAntibes Messages postés 491 Date d'inscription mardi 24 octobre 2000 Statut Membre Dernière intervention 18 novembre 2021 5
17 juin 2005 à 10:58
Merci bien ca marche super

j'ai un peu modifier des trucs pour le mettre a ma sauce, mais super !!!

par contre j'ai cette repetition :

choix=new Option("Veronique");
form1.perso.options[form1.perso.options.length]=choix;

choix=new Option("David");
form1.perso.options[form1.perso.options.length]=choix;

choix=new Option("demande de bon de livraison");
form1.sujet.options[form1.sujet.options.length]=)=choix;

choix=new Option("Demande de facture");
form1.sujet.options[form1.sujet.options.length]=choix;

As tu une solution pour l'eviter ?

MANUANTIBES
0
hippyz Messages postés 56 Date d'inscription vendredi 21 mai 2004 Statut Membre Dernière intervention 7 mai 2006
17 juin 2005 à 11:09
Comment ça tu as cette répétition je ne comprends pas, tu veux dire que tout ça se cumule dans le même select ???
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
ManuAntibes Messages postés 491 Date d'inscription mardi 24 octobre 2000 Statut Membre Dernière intervention 18 novembre 2021 5
17 juin 2005 à 14:57
bien oui j'ai modifier ton code pour etre plus en adequation avec mon projet

j'ai repris ton code mais j'ai supprimé les for

function trierMenu()
{
form1.perso.options.length=0;
form1.sujet.options.length=0;
Groupe=form1.Service.value;
if (Groupe == "1")
{
choix=new Option("Veronique");
form1.perso.options[form1.perso.options.length]=choix;
choix=new Option("David");
form1.perso.options[form1.perso.options.length]=choix;
choix=new Option("Edition d'un bon de livraison");
form1.sujet.options[form1.sujet.options.length]=choix;
choix=new Option("Edition d'une facture");
form1.sujet.options[form1.sujet.options.length]=choix;
}
if (Groupe == "2")
{
choix=new Option("Christophe");
form1.perso.options[form1.perso.options.length]=choix;
choix=new Option("Zorane");
form1.perso.options[form1.perso.options.length]=choix;
choix=new Option("Visite au restaurant");
form1.sujet.options[form1.sujet.options.length]=choix;
choix=new Option("demande de facturation");
form1.sujet.options[form1.sujet.options.length]=choix;
}

}

Comprends tu mieux ??

MANUANTIBES
0
Rejoignez-nous