SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Getting there... Willigogs's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    394
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Tabs with Show / Hide OnClick problem

    Hi there,

    I'm currently creating a page which requires a number of tabs, each with their own content window below. By clicking on each of the tabs you should be able to display JUST that tab's content window without having to load a separate page.

    I have a working example here, but the javascript needs to be incremented manually whenever a tab is added or removed (which is not ideal).

    My javascript experience is EXTREMELY limited, therefore would anyone be able to help in making the current javascript dynamic & so that the script doesn't have to be edited whenever tabs are added and removed?

    Any help or assistance would be greatly appreciated.

    I'll post the javascript here too in case anyone finds it handy:
    Code:
    function show(id){ 
    	for(x = 1; x <= 8; x++){
    	  if(id == x){
       		eval("document.getElementById('"+x+"').style.display='block'");
    	  }else{
    	   eval("document.getElementById('"+x+"').style.display='none'");
    	  }
    	}
    } 
    
    function switch2(id1){ 
    	
    	for(x = 101; x <= 108; x++){
    		var el = document.getElementById(x);
    		  if(id1 == x){
    		  	el.className = "xmenu selected"
    		  }else{
    		  	el.className = "xmenu"
    		  }
    	}
    }

  2. #2
    Getting there... Willigogs's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    394
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually scrub this thread!

    Thanks to a similar thread at the bottom of this page I managed to find "Tabtastic" which I've managed to implement very easily as seen here.

    Thanks for looking though guys


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •