Change Ctabview Active Tab With Link Or Button

Hi,

I was searching for help with click on link or button to change the active tab. I came across this thread My link , but it did not work for me. Then I figured out that with just a simple function, either you hard code the tab number, or passing the #tabx to the function, it works fine. And I just want to share in case someone else needs. Thanks all. How to use: just put the script anywhere on tab page, add link or button with onclick=‘changetab()’




<script>

	function changetab(){

                // PLEASE NOTE THIS IS NOT ADDING NEW TAB, IT JUST ACTIVATES #tab4

                // var id = tabnumber;

		var id = '#tab4';

		var pos = id.indexOf("#");

		if (pos>=0) {

			id = id.substring(pos);

		}

		var $tab=$(id);

		var $container=$tab.parent();

		$container.find('>ul a').removeClass('active');

		$container.find('>ul a[href="'+id+'"]').addClass('active');

		$container.children('div').hide();

		$tab.show();


		// you also can add new content to the tab by setting     

                // document.getElementById('mytab').innerHTML

         }       


</script>