Results 1 to 3 of 3

Thread: Ajax Dynamic Tab Script

  1. #1
    Join Date
    Aug 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Ajax Dynamic Tab Script

    1) Script Title: Ajax Dynamic Tab

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tent/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?

  2. #2
    Join Date
    May 2007
    Location
    England, UK
    Posts
    235
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default

    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:
    HTML Code:
    <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 Code:
    <?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:

    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:

    PHP Code:
    <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.

  3. #3
    Join Date
    Aug 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I just found your reply. Thank you very much for your suggestion. I'll give this a try.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •