Choix d'une liste enfonction d'une autre

Bonjour,

voilà, j'aimerais moderniser le site que j'ai créé, mai je ne suis pas un as du php.

Mon problème est que j'aimerais lier de liste de choix. Je m'explique: une première liste s'affiche, le visiteur choisit une option, et en fonction de cette option telte ou telle liste apparaît. Ma question est comment faire?

Merci par avance
Configuration: Windows XP
Firefox 2.0.0.13

1 réponse

  1. Slt, je crois avoir compris ce que tu recherche mais moi j'ai sous forme d'onglet, c'est du javascript:

    copie le code ci dessous est insére le la ou tu veux ke la liste apparait dans ta page
    Tu peux rajouter autant d'onglet que tu veux sur 2 liste maxi (si tu veux une présentations sous forme de liste, tu doit modifier la fonction onglet_box_afficher)

    je te souhaite bon courage!!!!

    <script type="text/javascript">
    function Onglet(titre,url){
    this.titre=titre;
    this.url=url;
    this.nombre=0;
    this.liens=new Array();
    this.texte=new Array();
    this.add_link=Onglet_add_link;
    this.afficher=Onglet_afficher;
    }
    function Onglet_add_link(texte, lien){
    this.liens[this.nombre]=lien;
    this.texte[this.nombre]=texte;
    this.nombre++;
    }
    function Onglet_afficher(){
    var i;
    if(this.nombre>0)
    document.write('<font color="#FF0000"><em><strong>'+this.titre+' >>>  </strong></em></font>');
    for (i=0;i<this.nombre;i++){
    document.write('<a href="'+this.liens[i]+'" onmouseover="Background=\'Img/btn_onclick2.png\'" onmouseout="Background=\'\'"></this.nombre;i++){><font color="#009933">'+this.texte[i]+'</font></a>');
    if(i<(this.nombre-1)) document.write(' - ');
    }
    }

    function Onglet_box(){
    this.nombre=0;
    this.onglets=new Array();
    this.ajouter_onglet=Onglet_box_ajouter_onglet;
    this.afficher=Onglet_box_afficher;
    }
    function Onglet_box_ajouter_onglet(titre,url){
    this.onglets[this.nombre]=new Onglet(titre,url);
    this.nombre++;
    }
    function Onglet_box_afficher(){
    document.write('<table border="0" cellspacing="0" height="40"><tr><td valign="top"> <table border="0" cellspacing="0" height="20"><tr>');
    for (i=0;i<this.nombre;i++){
    //Affichage Onglet
    document.write('<td id="header'+i+'" valign="top"><a href="'+this.onglets[i].url+'" onmouseover="javascript:ouvre(\''+i+'\')" ><strong>'+this.onglets[i].titre+'</strong></a>');
    if(i<(this.nombre-1)) document.write('</td><td> | ');
    document.write('</td>');
    }
    document.write('</tr></table></tr><tr><td>'); // colspan="'+this.nombre+'"
    for (i=0;i<this.nombre;i++){
    //Contenu Onglet
    document.write('<div id="div'+i+'">');
    this.onglets[i].afficher();
    document.write('</div>');
    }
    document.write('</td></tr></table>');
    nombre=this.nombre;
    }

    function ouvre(id){
    a=document.getElementById('div'+id);
    for (i=0;i<nombre;i++){
    document.getElementById('div'+i).style.display="none";
    document.getElementById('header'+i).style.background="#c0ffc0";
    }
    document.getElementById('header'+id).style.background="#7AF"
    document.getElementById('div'+id).style.display="block";
    }

    a=new Onglet_box();
    a.ajouter_onglet('Choix 1','fichier1.ext');
    a.onglets[1].add_link('Choix 1 1','fichier 1 1.ext');
    a.onglets[1].add_link('Choix 1 n','fichier 1 n.ext');
    a.ajouter_onglet('Choix 2','fichier2.ext');
    a.onglets[2].add_link('Choix 2 1','fichier 2 1.ext');
    a.onglets[2].add_link('Choix 2 n','fichier 2 n.ext');
    a.ajouter_onglet('Choix n','Choixn.ext');
    a.afficher(); //Affiche les liste
    ouvre(0); //Affiche l'onglet 0
    </script>
    0
    1. Merci, en faite j'ai fait plus simple, j'ai utilisé la fonction onchange et du javascript

      Mais ton script m'a l'air intéressant pour la suite.

      Matthias
      0