<div class="tab">
<button class="tablinks" onclick="openMenu(event, 'Pending')">Pending</button>
<button class="tablinks" onclick="openMenu(event, 'Completed')">Completed</button>
<button class="tablinks" onclick="openMenu(event, 'Rejected')">Rejected</button>
<button class="tablinks" onclick="openMenu(event, 'All')" id="defaultOpen">All</button>
</div>
<div id="Pending" class="tabcontent">
<%
perform db selection pending records
%>
<div id="All" class="tabcontent">
<%
perform db selection all records
%>
<script>
function openMenu(evt, Status) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(Status).style.display = "block";
evt.currentTarget.className += " active";
}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>
参考https://www.w3schools.com/howto/howto_js_tabs.asp示例。我开发了一个选项卡来显示不同的状态内容。我将执行记录状态更改,但我不知道如何在某些记录状态更改时刷新选项卡内容。
1条答案
按热度按时间tcomlyy61#
使用jQuery可以更快、更简单地执行操作: