PDA

View Full Version : Ajax Dynamic Tab Script



bluemoon562
11-19-2007, 04:40 AM
1) Script Title: Ajax Dynamic Tab

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

3) Describe problem: I love the Dynamic Tab script. However, I'd like to jump to the top of the web page and a specific tab.

I can jump to a tab on the same page but it takes me to the top of the tabbed section and not the top of the web page. And I can't jump to the a tab on the second page, only the page that I'm on.

Is there a way that I can refer to each tab as a web page link that would take me to the top of the web page and the right tab? :confused:

jc_gmk
11-19-2007, 10:30 AM
If i understand what your trying to do correctly; you want a link to reload the page but have a specified tab open by default?

You could use some PHP to do this.

first setup you links:


<a href="mypage.php?tab=1">Click here to reload the page with tab 1 opened</a>

<a href="mypage.php?tab=3">Click here to reload the page with tab 3 opened</a>

Then have some php get the value of the tab you want open by default:


<?php
$default_tab = $_GET['tab']; // This gets the tab number from the url
$selected = 'class="selected"'; // This is the text to add to the tab html
?>


If this is your tab html code:


<ul id="countrytabs" class="shadetabs">
<li><a href="external1.htm" rel="countrycontainer">Tab 1</a></li>
<li><a href="external2.htm" rel="countrycontainer">Tab 2</a></li>
<li><a href="external3.htm" rel="countrycontainer">Tab 3</a></li>
</ul>

change it to this:


<ul id="countrytabs" class="shadetabs">
<li><a <? if ($default_tab == 1) {print $selected;} ?> href="external1.htm" rel="countrycontainer">Tab 1</a></li>
<li><a <? if ($default_tab == 2) {print $selected;} ?> href="external2.htm" rel="countrycontainer">Tab 2</a></li>
<li><a <? if ($default_tab == 3) {print $selected;} ?> href="external3.htm" rel="countrycontainer">Tab 3</a></li>
</ul>
That should do it.

bluemoon562
12-13-2007, 05:38 AM
I just found your reply. Thank you very much for your suggestion. I'll give this a try.