PDA

View Full Version : How to make collapse closed by default?


bashy
01-11-2007, 04:27 PM
Hi

I have this bit of code, It has a collapse feature and i would like to know how
to set the code so that the box is closed by default please?

$nzbfiletable = "<table class=\"tborder\" cellpadding=\"$cellpadding\" cellspacing=\"$cellspacing\" border=\"0\" width=\"100%\" align=\"center\"><td class=\"tcat\" colspan=\"2\"><a style=\"float: right;\" href=\"#top\" onclick=\"return toggle_collapse('nzbfile" . $nzbfileid . "');\"><img id=\"collapseimg_nzbfile" . $nzbfileid . "\" src=\"" . $imgdir_button . "/collapse_tcat.gif\" alt=\"\" border=\"0\"></a>NZB File Contents</td></table>";
$nzbfiletable .= "<table cellspace=\"1\" style=\"\" id=\"collapseobj_nzbfile" . $nzbfileid . "\"><tr bgcolor=\"#B9CAE6\"><td><font face=\"Verdana\" size=\"1\">Subject</td><td><font face=\"Verdana\" size=\"1\">Group</td><td><font face=\"Verdana\" size=\"1\">Size (kb)</td><td><font face=\"Verdana\" size=\"1\">Parts</td><td><font face=\"Verdana\" size=\"1\">Poster</td></tr>";

RyanIMC
01-11-2007, 07:17 PM
I'm also looking for a way to do this

I've seen this,
https://vborg.vbsupport.ru/showthread.php?t=119931&highlight=collapsed+on+default but people without javascript cant reopen the box.

Or you could use this code after the box is created within the template that holds the box.

<script type="text/javascript">toggle_collapse('IdOfBoxToCollapse')</script>

But if you use that, when you reload the page it simply toggles the box open and closed which is probably also not what people want.

We need a close('IDOfBoxToCollapse') :)

BigJohnny
01-11-2007, 08:05 PM
no you just need some code in a template...

Here is one I use, it opens and closes when you click the arrow icon..

Replace all occurances of VARIABLE with whatever variable you choose to name it.

I dont know PHP all too well, so I dont know how you would work this into PHP but im sure you could figure something out.

you can see basically there is a a collapsable table, and the tbody which contains the information to be collapsed.

the rest is just a simple table template basically.... using another "bits" template for the content.


<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%">
<thead>
<tr>
<td class="tcat" colspan="5" align="left" width="100%">
<a style="float:$stylevar[left]" href="#top" onclick="return toggle_collapse('VARIABLE')">Main Header</a>
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('VARIABLE')"><img id="collapseimg_VARIABLE" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_VARIABLE].gif" alt="" border="0" /></a>
</td>
</tr>
</thead>
<tbody id="collapseobj_VARIABLE" style="$vbcollapse[collapseobj_VARIABLE]">

<td class="thead" width="2%" align="left"></td>
<td class="thead" width="11%" align="left"><b>Title 1</b></td>
<td class="thead" width="49%" align="left"><b>Title 2</b></td>
<td class="thead" width="18%" align="left"><b>Title 3</b></td>
<td class="thead" width="26%" align="left"><b>Title 4</b></td>

$tablebits

</tbody>
</table>
<div class="spacer"></div>
<br />


errr... sorry i misread the topic... so i may not have even answered your question... apologies for the wasted space :(

bashy
01-11-2007, 08:26 PM
What i am after is having the box closed for default, any ideas, i already have the box and collapse objects

Adrian Schneider
01-11-2007, 08:28 PM
In your template have it show the collapsed image by default, and also have the box with the following style applied: display: none

bashy
01-12-2007, 05:06 AM
Hi SirAdrian. The code that i have is in the 1st post, can you please advise where it would go in that code please?

Dismounted
01-12-2007, 07:47 AM
Answered :)
https://vborg.vbsupport.ru/showthread.php?t=136063

bashy
01-12-2007, 03:32 PM
Cheers dismounted ;)

reddyink
11-03-2007, 01:54 AM
Thanks for collapsed style code
I added display:none style in my object. all rows are now collapsed by default. Is there a way that we can set first row to be expanded and all others to be collapsed. then user can click on collapsed one's to expand.

Can we set that option in same box, to first row to be expanded and all others to be collapsed when page loads.

Appreciate any help
Thanks