我在开放式购物车中工作。在我的订单信息页面中,我有一些自定义选项卡,其中一个选项卡被命名为HX endicia标签。
<a href="#tab-label"><?php echo "HX Endicia Labels"; ?></a> // link to tab
<div id="tab-label" class="vtabs-content" style="display: none;"> // tab content, its by default display none when page loads.
在这个选项卡上,我显示了表中数据库中的一些记录。在每一行上,我都有删除链接,从数据库中删除当前行。当我点击我的删除链接时,我会调用控制器中的delete_label方法,并从数据库中删除该行,直到现在它还可以正常工作。在函数结束时,我重新加载当前的orderinfo页面。当我删除记录时,页面会被刷新。刷新页面时,默认情况下会打开我的第一个选项卡。我想要的是通过这个删除功能重新加载页面时打开我的"#tab标签"选项卡。为此,我这样编码。
public function Delete_label()
{
/* my code to delete label */
$this->info(); // refreshing my page
echo " <script type="text/javascript">
document.getElementById('tab-label').style.display = 'block';
</script>
";
}
它不起作用。
您需要将刷新的instad重定向到以所需活动选项卡结束的页面
exp:用于删除的html表单//其他输入
public function Delete_label()
{
$tab = $_POST["showed"];//get the value from the hidden input
header('Location: '.$currentUrl.$tab);
}
在刷新的页面中,您执行以下操作:
tab= window.location.hash.substr(1);//get the end of the url '#tab-label'
if(tab) {
document.getElementById(tab).style.display = 'block';//show the hidden tab
}