Scroll To Top

Enter a query to search our site. Note that you can use "*" and "?" as wildcards. Enclosing more than one word in double quotes ("CSS Layout") will search for the exact phrase.

PVII Knowledge Base

1. Select a product ...
2. Select category ...
3. Search the Knowledge Base...

Question #283

Is there a way to trigger a specific link in the Tree Menu Magic 2 (TMM2) system remotely, by clicking a link somewhere else on the page?

The Answer

Prepared Jan. 2010 by Gerry Jacobsen, PVII

To open a specific menu item of the Tree Menu Magic 2 (TMM2) system by specifying the text of the link you can use this new script function:

1. Open the p7TMMscripts.js file and scroll to the end of the page. Add a new blank line and then copy and paste this new function into that new line:

function P7_TMMtrigText(d,an){
   var i,h,an,tA,pp,a,im;
      el=document.getElementById(d);
    if(d){
      tA=el.getElementsByTagName('A');
    for(i=0;i<tA.length;i++){;
       if(an==tA[i].firstChild.nodeValue){
      pp=tA[i].parentNode;
        while(pp){
       if(pp.tagName&&pp.tagName=='LI'){
          P7_TMMsetClass(pp,'li_current_mark');
          a=pp.getElementsByTagName('A');
        if(a&&a[0]){
           P7_TMMsetClass(a[0],'current_mark');
         if(a[0].hasImg){
            im=a[0].getElementsByTagName('IMG')[0];
          im.mark=true;
            im.src=im.p7imgswap[3];
         }
         if(a[0].tmmsub){
            P7_TMMopen(a[0],1);
         }
        }
       }
       else{
          if(pp==el){
         break;
        }
       }
         pp=pp.parentNode;
      }
     }
    }
   }
}

2. Save and close the file.

3. You would assign a function call (behavior) to any normal link on your page, like this:

<a href="#" onclick="P7_TMMtrigText('p7TMM_1','MyLink');return false">Open to MyLink</a>

The first argument is the ID of the TMM2 system that the link appears in ( 'p7TMM_1' ) and the second argument is the text that appears in the menu link you wish to open.

Back to the questions list