I'd like to preface this by saying I'm more of a web designer as opposed to a developer, though I do have limited knowledge in PHP and JS. I've created a site for a close friend. I've set up several "tabs" within the service page and I'm trying to link to a specific tab from the homepage. For example, if I click "Technology and Architecture" on the homepage, it will link to the service page and display the "Technology and Architecture" tab instead of the default. I've tried several different methods to get this to work, but they are all failing me. It's a little different from all of the help I've found on this site - in that my tabs are built slightly different. They are not lists, and are actually comprised of multiple elements. I'm struggling to find a solution for my specific layout.
Here's my tab code on the services page:
<div class="col-3">
<button class="tablinks" onclick="openCity(event, 'strat')"
id="defaultOpen">
<div class="tab-wrap-ltblue">
<div class="strategict tab4mobile" style="height: 100px;"> </div>
<div class="tablink-head stories mobile-no"><h4>Strategic Innovation</h4>
</div></div></button>
</div>
<div class="col-3">
<button class="tablinks" onclick="openCity(event, 'analysis')">
<div class="tab-wrap-blue">
<div class="analysist tab4mobile" style="height: 100px;"> </div>
<div class="tablink-head stories mobile-no"><h4>Integrated Business
Analysis</h4></div></div></a></button>
</div>
<div class="col-3">
<button class="tablinks tech" onclick="openCity(event, 'tech')">
<div class="tab-wrap-green">
<div class="archt tab4mobile" style="height: 100px;"> </div><div
class="tablink-head stories mobile-no"><h4>Technology and Architecture</h4>
</div></div></button>
</div>
and the java to make it work:
<script>
function openCity(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent.style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks.className = tablinks.className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>
The links on the homepage are simple:
<a href="services.php"><div class="help-btns"> Learn More</div></a>
What would be the easiest way to accomplish this? Thank you so much for your help! I'm not trying to open a new "browser" tab - but a navigation tab within a page of my site.