We help IT Professionals succeed at work.

Client script to switch TabPanel

DerekWatling asked
Last Modified: 2011-02-25
I am looking for the client-side script to switch the active TabPanel as if you clicked on the tab itself. In my page I have a HyperLink that I want to simply call javascript to change the active TabPanel.
Watch Question

you simply give to each panel an id
Then let each link call a javascript method which will switch showing these panels such as the following code:
<a href="javascript:OpenTab(1);"> Open Tab 1 </a>
<a href="javascript:OpenTab(2);"> Open Tab 2 </a> 
<div id="tab1"> This tab 1 content </div>
<div id="tab2"> This tab 2 content </div>
<script language="javascript" type="text/javascript">
function OpenTab(tabId)
  document.getElementById('tab1').style.display = 'none';
  document.getElementById('tab2').style.display = 'none';
  document.getElementById('tab'+ tabId).style.display = 'block';

Open in new window

This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.