gpt4 book ai didi

php - 滚动浏览 MySQL 数据时显示正确的选项卡

转载 作者:行者123 更新时间:2023-11-30 01:31:46 25 4
gpt4 key购买 nike

我有一个页面,其中包含三个选项卡,每个选项卡都带有标签。单击标签可打开每个选项卡(通过显示/隐藏 div)。每个选项卡都包含 MySQL 数据,每个选项卡底部的箭头可转到数据的下一个“页面”。

我的问题,当您单击箭头时,页面确实会转到下一页数据,但默认选项卡(选项卡1)可见,其他两个隐藏,因此如果您在选项卡二上,请点击下一个箭头,您将返回到 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>

最佳答案

嗨,您必须在参数 #tab1 或 #tab2 或 #tab3 中传递选项卡 ID,如果您在查询字符串中获得 #tab2 并移动到 #tab3,则必须删除 #tab2

关于php - 滚动浏览 MySQL 数据时显示正确的选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17365850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com