I am having problems with collapsible/expandable links. When the web page first opens, the links should be iin a closed or collapsed state. Click the link once and the text opens directly below it. Click it again and the link closes (the text goes away below the link). I’m using this toggle javascript:
<script type=“text/javascript”>
function toggleObj(obj,init,lshow,lhide,swap,set,cname) {
var Ar = new Array(obj,init,lshow,lhide,swap,set,cname);
var elstyle = document.getElementById(obj).style;
if (Ar[4]) var swstyle = document.getElementById(swap).style;
var text = document.getElementById(obj + “-tog”);
if (Ar[1]==‘hide’) { //hide object
if (Ar[5]==‘1’) document.cookie=Ar[6]+‘=hide; path=/’;
Ar[1]=‘show’;
elstyle.display = ‘none’;
if(Ar[4]) swstyle.display = ‘block’;
copy=‘<a class=“wikilink” ‘;
copy+=‘href="javascript:toggleObj(\’’+Ar[0]+’\‘,\’‘+Ar[1]+’\‘,\’‘+Ar[2]+’\‘,\’‘;
copy+= Ar[3]+’\‘,\’‘+Ar[4]+’\‘,\’‘+Ar[5]+’\‘,\’‘+Ar[6]+’\‘);">’+Ar[2]+‘</a>’;
text.innerHTML = copy;
}
else if (Ar[1]==‘show’) { //show object
if (Ar[5]==‘1’) document.cookie=Ar[6]+‘=show; path=/’;
Ar[1]=‘hide’;
elstyle.display = ‘block’;
if(Ar[4]) swstyle.display = ‘none’;
copy=‘<a class=“wikilink” ‘;
copy+=‘href="javascript:toggleObj(\’’+Ar[0]+’\‘,\’‘+Ar[1]+’\‘,\’‘+Ar[2]+’\‘,\’‘;
copy+= Ar[3]+’\‘,\’‘+Ar[4]+’\‘,\’‘+Ar[5]+’\‘,\’‘+Ar[6]+’\‘);">’+Ar[3]+‘</a>’;
text.innerHTML = copy;
}
}
</script>
Then, in the body of the html, I have something like:
<li><span id=“lac10-tog” class=“toggle”><a class=“wikilink” href=“javascript:toggleObj(‘lac10’,‘show’,
‘Link to be clicked’,‘Link to be clicked’,‘’,‘0’,‘’)” >Link to be clicked</a></span>
<style type=‘text/css’>
#lac10 { display:none; }
</style>
</li>
<div class=‘hidediv faqanswer’ id=‘lac10’>
<p>text that expands and collapses below the clicked link</p> </div>
The problem is that when the number of expandable links reaches 20 or so, the links start opening in the expanded state instead of the collapsed state. I want the links to always start out in the collapsed state. Interestingly, the whole thing breaks only when it’s an shtml page, and html doesn’t seem to cause problems.Sometimes, it only breaks when we upload it to the server. Any ideas? Thanks. Polly