So I would like to add functionality to my page that allows the user to toggle visibility on only the information they want, in several sets, but that are interspersed among each other. I initially tried it according to this link, like so:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE></TITLE>
<link href="style.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function unhide(divID) {
var item = document.getElementById(divID);
if (item) {
item.className=(item.className=='hidden')?'unhidden':'hidden';
}
}
</script>
</HEAD>
<BODY>
<P><a href="javascript:unhide('iron');">Toggle Silver Veins</a> | <a href="javascript:unhide('iron');">Toggle Iron Veins</a> | <a href="javascript:unhide('gold');">Toggle Gold Veins</a> | <a href="javascript:unhide('platinum');">Toggle Platinum Veins</a></p>
<div id="gold" class="hidden">this is a gold</div>
<div id="iron" class="hidden"> this is an iron</div>
<div id="gold" class="hidden">this is a gold again</div>
<div id="platinum" class="hidden"> this is a platinum</div>
<div id="silver" class="hidden">this is a silver</div>
</BODY>
</HTML>
Please pardon the poor formatting, I experiment messily.
Style.css only contains
.hidden { display: none; }
.unhidden { display: block; }
That worked well enough for the ones that had only a single instance, but for the "gold," it would only toggle the first div with the id. I then tried to glean information from this post and this post, but wasn't ultimately able to figure it out to my satisfaction.
The first post would work with multiple instances of the same set, but I'm not savvy enough to make it work for several instances of several different sets without duplicating the script four times. I'd appreciate your advice, thank you!