What is on your test board bears no resemblance to the code I provided above...
Why are you using duplicate
.forabg
elements for each category? There is absolutely no need for such duplication in a show/hide toggle! The following is a COMPLETE replacement for your current category toggle function, and it includes cookie support:
Code: Select all
<div class="forabg">
<div class="inner"><span class="corners-top"><span></span></span>
<ul class="topiclist" style="position:relative">
<li class="header">
<dl class="icon">
<dt>TITLE</dt>
</dl>
</li>
<img src="./styles/prosilver/theme/images/hide.png" style="position:absolute;right:5px;bottom:5px" onclick="toggleCat(this)" />
</ul><ul id="c{FORUM_ID}" class="topiclist forums" style="display:block">
<li class="row">
<div style="text-align: center;">
CONTENT HERE
</div>
</li>
</ul>
<span class="corners-bottom"><span></span></span></div>
</div>
Note that I removed the DIV tag which enclosed the
.forabg
element, as it's not needed. You also don't need the duplicate "hide"
.forabg
element any more. You will also need the following javascript:
Code: Select all
<script type="text/javascript">
function toggleCat(button) {
var cat = button.parentNode.nextSibling;
if (cat.style.display == 'none') {
button.src = "./styles/prosilver/theme/images/hide.png";
document.cookie = '_' + cat.id + '=; path=/; expires=Wed, 1 Jan 2020 00:00:00 GMT;';
}
else {
button.src = "./styles/prosilver/theme/images/show.png";
document.cookie = '_' + cat.id + '=1; path=/; expires=Wed, 1 Jan 2020 00:00:00 GMT;';
}
$(cat).slideToggle('slow');
}
cookies = document.cookie.split('; ');
for (i in cookies) {
if (cookies[i].charAt(0) == '_') {
cookie = cookies[i].split('=');
if (cookie[1] == '1') {
cid = cookie[0].substring(1);
if (document.getElementById(cid)) {
document.getElementById(cid).style.display='none';
}
}
}
}
</script>
It should be placed at the end of
forumlist_body.html
.