PDA

View Full Version : Collapsable menus?


Fou-Lu
05-09-2003, 11:21 PM
So, I have this code that my friend gave me, and I use it on my VB. Its to collapse the posts. Anyway, the people at vbulletin couldn't help me out, so I thought that I would try here. Heres what it looks like:

<script language="JavaScript" type="text/javascript">
<!--
function expand(listID) {
if (listID.style.display=="none") {
listID.style.display="";
}
else {
listID.style.display="none";
}
window.event.cancelBubble=true;
}
function contract(listID) {
if (listID.style.display=="show") {
listID.style.display="";
}
else {
listID.style.display="none";
}
window.event.cancelBubble=true;
}
//-->
</script>

Then, at each post there is a section with two codes for it, one is for what it will show when its collapsed, and the other is what will show when its expanded. Also, the links for opening/closing each post:

//This ones for when the post is closed:
<DIV id="p$post[postid]h" style="display:none">
//And the link to open it
<a style="cursor:pointer;cursor:hand" name="sign" onClick="expand(p$post[postid]e);contract(p$post[postid]h);">

//And for when its open, and you want it to close:
<DIV id="p$post[postid]e" style="display:show">
//And the link to close it
<a style="cursor:pointer;cursor:hand" name="sign" onClick="contract(p$post[postid]e);expand(p$post[postid]h);">


My question is, is there a way to add a link at the top to my page, that has something like (Collapse All | Expand All) that can be used with this code? I think I mentioned, that I'm pretty much javascript illeterate, so if someone can help me out, that would be great!