2013-06-28 41 views
0

我有一個由三個標籤組成的標籤頁。點擊標籤打開每個標籤(通過顯示/隱藏div)。每個選項卡都包含MySQL數據,每個選項卡底部的箭頭將轉到數據的下一個「頁面」。滾動瀏覽MySQL數據時顯示正確的選項卡

我的問題是,當您單擊箭頭時,頁面確實會轉到數據的下一頁,但是默認選項卡(tab1)變得可見,另外兩個隱藏,所以如果您在選項卡2上,擊中下一個箭頭,你將被帶回到tab1並且必須打開tab3才能看到數據。

Link to site here

改變標籤的可見性的腳本是在這裏:

<script type="text/javascript"> 
$(document).ready(function() { 
    $("div.tab-headers>a").click(function() { 
     // Grab the href of the header 
     var _href = $(this).attr("href"); 

     // Remove the first character (i.e. the "#") 
     _href = _href.substring(1); 

     // show this tab 
     tabify(_href); 
    }); 
    tabify(); 
}); 

function tabify(_tab) { 
    // Hide all the tabs 
    $(".tab").hide(); 

    // If valid show tab, otherwise show the first one 
    if (_tab) { 
     $(".tab a[name=" + _tab + "]").parent().show(); 
    } else { 
     $(".tab").first().show(); 
    } 
} 

// On page load... 
$(document).ready(function() { 
    // Show our "default" tab. 
    // You may wish to grab the current hash value from the URL and display the appropriate one 
    tabify(); 
}); 
</script> 

和TAB2的代碼是:

<div class="tab"> 
<a name="tab2"></a> 
<img src="images/glossary_shiptype.png" width="1643" height="952" /> 

    <div class="glossary_body"> 
    <table width="740" border="0"> 
    <?php do { ?> 
     <tr> 
     <td><?php echo $row_ship_type['term']; ?>:</td> 
     <td><?php echo $row_ship_type['definition']; ?></td> 
     </tr> 
     <?php } while ($row_ship_type = mysql_fetch_assoc($ship_type)); ?> 
    </table> 
    </div> 

    <div class="glossary_arrow_back"> 
    <?php if ($pageNum_ship_type > 0) { // Show if not first page ?> 
      <a href="<?php printf("%s?pageNum_ship_type=%d%s", $currentPage, max(0, $pageNum_ship_type - 1), $queryString_ship_type); ?>"><img src="images/arrow_left.png" /></a> 
      <?php } // Show if not first page ?> 
    </div> 

    <div class="glossary_arrow_forward"> 
    <?php if ($pageNum_ship_type < $totalPages_ship_type) { // Show if not last page ?> 
      <a href="<?php printf("%s?pageNum_ship_type=%d%s", $currentPage, min($totalPages_ship_type, $pageNum_ship_type + 1), $queryString_ship_type); ?>"><img src="images/arrow_right.png" /></a> 
      <?php } // Show if not last page ?> 
    </div> 
</div> 

回答

0

嗨,你必須通過標籤的ID在paramater#TAB1或#tab2或#tab3,如果您在查詢字符串中獲得#tab2並將其移至#tab3,則必須刪除#tab2

+0

對不起,我在所有選項卡中的答案有點遺失,你能突出顯示我需要修改的代碼的區域嗎?謝謝 – user2406993

+0

<?php printf(「%s?pageNum_ship_type =%d%s%s」,$ currentPage,min($ totalPages_ship_type,$ pageNum_ship_type + 1),$ queryString_ship_type,$ tab_id); ?> –

+0

這兩個東西都添加了%s和$ tab_id –

相關問題