View Full Version : How to adjust [initialstate] in DIV toggler...

05-21-2009, 06:25 AM
Hi - hopefully someone can give me a hand here...
A while back I bookmarked some DIV toggler code at Dynamic Drive (www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm). It wasn't until recently that I wanted to use it, but found that the code had been updated - and I can't find any more reference info for the old code, which has already been added to my site. Everything still works, I just need to know how to control the initial state of the DIV togglers. I need some DIVs to start open, some to start closed, and all of them to be able to stay open or closed as certain pages are navigated.

Here's the code as supplied by Dynamic Drive - the portion in red is what I'd like to know more about.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>

<script type="text/javascript" src="animatedcollapse.js">

* Animated Collapsible DIV- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more




<p><b>Example 2:</b></p>

<a href="javascript:collapse2.slideit()">Show/ Hide DIV</a>
<div id="cat" style="width: 300px; background-color: #99E0FB;">

<!--Your DIV content as follows. Note to add CSS padding or margins, do it inside a DIV within the Collapsible DIV -->
<div style="padding: 0 5px">
<h3>Content inside DIV!</h3>
<h3>Content inside DIV!</h3>
<h4>Note: No CSS height attribute defined. Persistence enabled.</h4>


<script type="text/javascript">

//Syntax: var uniquevar=new animatedcollapse("DIV_id", animatetime_milisec, enablepersist(true/fase), [initialstate] )
var collapse2=new animatedcollapse("cat", 650, true)



If anyone can help me out, I'd greatly appreciate it.