Avatar of DerekWatling
DerekWatling
Flag for South Africa asked on

Client script to switch TabPanel

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.
AJAXASP.NET

Avatar of undefined
Last Comment
DerekWatling

8/22/2022 - Mon
amrelgarhy81

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';
}
</script>

Open in new window

ASKER CERTIFIED SOLUTION
DerekWatling

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes