Web Analytics Made Easy -
StatCounter Tab-menu, multiple instances - CodingForum

Announcement

Collapse
No announcement yet.

Tab-menu, multiple instances

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tab-menu, multiple instances

    Hi,

    I've written a small javascript that can handle tabs. It's very simple but it works! I've posted the code below. Now the thing is that I would like to have two (or maybe more) different tab-menus on one page. With the current script, that doen'st really work, because the variables previoustab and previouspane try to store information on both menu's. So that get's in each others way.

    Now I know about object oriented programming (and creating different instances of objects) form my experience with PHP. But I don't understand how to do this with javascript and my script in particular.

    So is there anyone that can put my in the right direction with making this script compatible for multiple instances?

    Thanx in advance!

    Cheers Michiel


    PS Any additional comments on the script are always welcome
    Code:
    <!--
    
    var previoustab;
    var previouspane;
    
    function clicktab(tab, pane) {
      if(document.getElementById) {
      tab.className = 'current'
      if(previouspane) {
        if(previouspane != pane) {  
          document.getElementById(previouspane).style.display = 'none';
          document.getElementById(previoustab).className = '_';
        }
      }
      document.getElementById(pane).style.display = 'block';
      previoustab = tab.id;
      previouspane = pane;
    }
    
    
    
    function hovertab(tab) {
      if(previoustab != tab.id) {
        tab.className = 'hover';
      }
    }
    
    function outtab(tab) {
      if(previoustab != tab.id) {
        tab.className = '_';
      }
    }
    
    //-->

  • #2
    http://www.vicsjavascripts.org.uk/MenuTab/MenuTab.htm
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

    Comment

    Working...
    X