Index du Forum » » Questions

Auteur

Menu déroulant
PhilGuen
995      

  Posté : 07-08-2008 09:08

Je ne suis pas l'auteur initial du code trouvé il y a plusieurs années sur le web, mais je l'ai pas mal modifié. J'ai également codé pour alimenter les lignes du menu à partir d'une table sql.Si ca intéresse, je peux donner un exemple.
entre les balises "head"


  <SCRIPT Language=\"!javascript!\">
   var DateMaintenant = new Date();
   var DateExpire = new Date();
   DateExpire.setFullYear(DateMaintenant.getFullYear()+1);

     function toggle(node,cat_menu) {
        var nextDIV = node.nextSibling;

        // find the next DIV
        while(nextDIV.nodeName != \"DIV\") {
           nextDIV = nextDIV.nextSibling;
        }

        // Unfold the branch if it isn't visible
        if (nextDIV.style.display == 'none') {
              ;// Change the image (if there is an image)
              ;if (node.childNodes.length > 0) {
              ;     if (node.childNodes.item(0).nodeName == \"IMG\") {
              ;          node.childNodes.it em(0).src = \"images/minus.gif\";
              ;     }
              ; }
              ; nextDIV.style.display = 'block';
              ; flag_expand_menu = 1;
        } else {
              ; // Collapse the branch if it IS visible
              ; // Change the image (if there is an image)
              ; if (node.childNodes.length > 0) {
              ;      if (node.childNodes.item(0).nodeName == \"IMG\") {
              ;           node.childNo des.item(0).src = \"images/plus.gif\";
              ;      }
              ; }
              ; nextDIV.style.display = 'none';
              ; flag_expand_menu = 0;
        }
     !document.cookie!=cat_menu+'='+flag_expand_menu +';expires='+DateExpire.toGMTString();
     <!-- alert(!document.cookie!); -->
    }
  </SCRIPT>



entre les balises "body"



<table border = \"0\" cellspacing = \"0\" cellpadding = \"0\">
      <tr>
          <td>
              ; ";
              ; $flag_expand = $_COOKIE[101];
              ; if ($flag_expand == 1){
              ;          $imagefolder = "images/minus.gif";
              ;       }else{
              ;          $imagefolder = "images/plus.gif";
              ;       }
              ; $content.="
              ; <a !onclick! = \"{toggle(this,101);}\" class = \"folder\" style = \"cursor:hand\">
              ;       <img src = ".$imagefolder.">
              ;       <b>Ma première ligne de menu</b>
              ; </a>
              ;      ";
              ;       if ($flag_expand == 1){
              ;          $content .= "<div style = \"display:yes;\">";
              ;       }else{
              ;          $content .= "<div style = \"display:none;\">";
              ;       }
              ;       $content .="
              ;       <table border = \"0\" cellspacing = \"0\" cellpadding = \"0\">
              ;           <tr> < br />              ;                <td width = \"15\"></td>
              ;                <td>
              ;                      
              ;                    <img src = 'images/blocks/som_module.gif' width = '15' height = '10' hspace = '2'>
              ;                     <a href = 'monlien1'>
              ;                        Mon premier sous-menu
              ;                     </a>
              ;                </td>
              ;              </tr>
              ;       </table>
              ;       <table border = \"0\" cellspacing = \"0\" cellpadding = \"0\">
              ;           <tr> < br />              ;                <td width = \"15\"></td>
              ;                <td>
              ;                      
              ;                    <img src = 'images/blocks/som_module.gif' width = '15' height = '10' hspace = '2'>
              ;                     <a href = 'monlien2'>
              ;                        Mon deuxième sous-menu
              ;                     </a>
              ;                </td>
              ;              </tr>
              ;       </table>
              ;       <table border = \"0\" cellspacing = \"0\" cellpadding = \"0\">
              ;           <tr> < br />              ;                <td width = \"15\"></td>
              ;                <td>
              ;                      
              ;                    <img src = 'images/blocks/som_module.gif' width = '15' height = '10' hspace = '2'>
              ;                     <a href = 'monlien3>
              ;                        Mon troisième sous-menu
              ;                     </a>
              ;                </td>
              ;              </tr>
              ;       </table>
              ;       </div>
          </td>
      </tr>
      </table><br>



(enlever les ! entourant !document.cookie! générés lors de la création de ce message)
à renouveler pour chaque ligne de menu



Cet article provient de NPDS

http://www.npds.org/viewtopic.php?topic=19930&forum=9