Dynamic JavaScript Tabs
This is some code that I wrote to create dynamic tabs. I use it for forms where I have a lot of fields and a good percentage are "advanced" or otherwise not important enough to have visible immediately. The CSS is based on ideas from Silverorange Labs and the JS code is mine. The code is released under the MIT license which basically means you can do what you like with it as long as you don't blame me!
Download
Subversion
The very latest version of the code is in my subversion repository at: http://svn.akrabat.com/svn/dynamic_tabs/trunk/
Basic tutorial
It's not hard to use and I've included a sample html file in the zip archive. The basics are:
<div id="tab-container">
<div class="tab-content">
<h1 class="tab" title="title for page 1">Page 1</h1>
<p>This is the content of tab 1</p>
</div>
<div class="tab-content">
<h1 class="tab" title="title for page 2">Page 2</h1>
<p>This is the content of tab 2</p>
</div>
<div class="tab-content">
<h1 class="tab" title="title for page 3">Page 3</h1>
<p>This is the content of tab 3</p>
</div>
</div>
<script type="text/javascript" src="abs.js"></script>
i.e. you need a "tab-container" and then each tab is contained in a "tab-content" and we use a "tab" to sort out the title. The nice thing is that it degrades really nicely!
Change Log
- 22/Mar/2005: version 1.0.0
-
- Initial release.
- 28/Mar/2005: version 1.0.1
-
- Gracefully handle the case when there is no container id.
- 21/Dec/2005: version 1.0.2
-
- Patch from Áncor & Imobach González Sosa to allow for multiple tab containers
- 17/Jan/2006: version 1.0.3
-
- Fixed version number at top of file
- Added this Change Log
- Fixed CSS as noted by Adam Fortuna of www.dyoit.com
- Patch from Simon H to add tab ids for other scripts to hook into

March 29th, 2006 at 01:19 #
Thanks alot of coming up with this. Works flawlessly.
April 4th, 2006 at 10:32 #
good work
April 4th, 2006 at 10:41 #
Thanks guys.
June 29th, 2006 at 02:34 #
Good job!
It's, however, should come along with more document because not everyone can dig into your code and understand all.
But this is really a dynamic tab strip!
November 9th, 2006 at 20:28 #
Wow Rob, This is really cool!
November 9th, 2006 at 21:57 #
Thanks Matt!
November 23rd, 2007 at 11:31 #
nice… thanks a lot!