それぞれにラベルが付いた 3 つのタブで構成されるページがあります。ラベルをクリックすると、各タブが開きます (div の表示/非表示によって)。各タブには MySQL データが含まれており、各タブの下部に矢印があり、データの次の「ページ」に移動します。
私の問題、矢印をクリックすると、ページは実際にデータの次のページに移動しますが、デフォルトのタブ (tab1) が表示され、他の 2 つが非表示になるため、タブ 2 を使用している場合は、次の矢印を押しますの場合、tab1 に戻り、データを表示するには tab3 を押す必要があります。
タブの表示を変更するスクリプトは次のとおりです。
<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>