Forum Moderators: open
I want to run 2 instances of this script [akrabat.com...]
On the same page.
So i want one set of tabs and then a bit further down another set of tabs, both containing different content.
How do I get the same script to work twice on the same page, when it comes to javascript I am about as good as cut and paste and thats it.
So if someone could tell me what to do then it would be much appreciated.
However, you could modify the script like so to potentially meet your needs.
1. Remove the call to BuildTabs() and ActivateTab(0) from the .js file.
2. Modify BuildTabs and ActivateTab functions to take a parameter with the id value of the tab container:
function BuildTabs( containerId )
function ActivateTab( containerId, activeTabIndex )
3. In both of those functions, replace this line:
tabContainer = document.getElementById('tab-container');
with this:
tabContainer = document.getElementById(containerId);
4. In your HTML file, add a function like this:
function initTabs()
{
BuildTabs('yourFirstContainer');
ActivateTab('yourFirstContainer',0);
BuildTabs('yourSecondContainer');
ActivateTab('yourSecondContainer',0);
// Add as many tab sets as you want
}
5. Call this function in your body onload event:
<body onload="initTabs();">
That should work. Good luck.