Hello! I’m new here and hoping for some help. 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 “nonclinical” on the homepage, it will link to the service page and display the “clinical” tab instead of the default. I’ve tried several different methods to get this to work, but they are all failing me.
Here’s my tab code on the services page:
[code]<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:
[code]<script>
function openCity(evt, cityName) {
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(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:
[code]<a href=”services.php”><div class=”help-btns”> Learn More</div></a>
What would be the easiest way to accomplish this?
Edited by site staff: Inserted code tags.