/    Sign up×
Community /Pin to ProfileBookmark

Expand/Callapse All Help!

Hello,

I woould like to add 2 links to this code. One to “expand all” panels and the other to “callapse all”. Can anyone please help?

[CODE]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
<br>
<style>

#tables .tableMainSub {color: #517191; font-family: arial, helvetica, sans-serif; font-size: 11px; line-height: 18px; font-weight: normal; background: #D3DCEE; text-indent: 10px; vertical-align: middle; height: 20px; border: 1px solid #9FB9D6; cursor: hand; width:100%;}

#tables .tableCellLeft {vertical-align:top; border: #9FB9D6 solid 1px; color: #000000; font-family: arial, helvetica, sans-serif; font-size: 11px; font-weight: normal; padding:5px; }

</style>
</head><body onLoad=”initPanels();”>
<!–Start Accordion–>
<div id=”tables”>
<table id=”paneltable” border=”0″ cellpadding=”1″ cellspacing=”1″ width=”100%”>
<tr valign=”top”>
<td class=”tableMainSub” onClick=”ToggleRowVisibility(‘paneltable’,1);”><img src=”images/minus_blue.gif” name=”paneltable.1″ border=”0″ >&nbsp;&nbsp;Header 1</td>
</tr>
<tr valign=”top”>
<td class=”tableCellLeft”><!–Start Accordion Content–>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
<!–End Accordion Content–>
</td>
</tr>
<tr valign=”top”>
<td class=”tableMainSub” onClick=”ToggleRowVisibility(‘paneltable’,3);”><img src=”images/minus_blue.gif” name=”paneltable.3″ border=”0″ >&nbsp;&nbsp;Header 2</td>
</tr>
<tr valign=”top”>
<td class=”tableCellLeft”><!–Start Accordion Content–>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
<!–End Accordion Content–>
</td>
</tr>
<tr valign=”top”>
<td class=”tableMainSub” onClick=”ToggleRowVisibility(‘paneltable’,5);”><img src=”images/minus_blue.gif” name=”paneltable.5″ border=”0″ >&nbsp;&nbsp;Header 3</td>
</tr>
<tr valign=”top”>
<td class=”tableCellLeft”><!–Start Accordion Content–>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
<!–End Accordion Content–>
</td>
</tr>
</table>
<!–End Accordion–>
</div>
<script>
<!–

function initPanels()
{
// Pre-collapse some panels, as an example (assumes all panels initially visible)
ToggleRowVisibility(“paneltable”,1);
ToggleRowVisibility(“paneltable”,3);
ToggleRowVisibility(“paneltable”,5);

}

imgExpand = new Image();
imgCollapse = new Image();
imgExpand.src = “images/plus_blue.gif”;
imgCollapse.src = “images/minus_blue.gif”;

</script>
<script>

// Panel Functions
/////////////////////////////////////////////////////////////////////////////////////////////////////
function ChangeRowVisibility(tableName, strVisibility, intRowIndex)
{
if(strVisibility == “visible”)
{
document.getElementById(tableName).rows[intRowIndex].style.display = “block”;
}
else if(strVisibility == “collapse”)
{
document.getElementById(tableName).rows[intRowIndex].style.display = “none”;
}
}

function ToggleRowVisibility(tableName, intRowIndex)
{

var currentSetting = document.getElementById(tableName).rows[intRowIndex].style.display;
if (currentSetting==”none”)
{
ChangeRowVisibility(tableName,”visible”, intRowIndex);
document.images[tableName+”.”+intRowIndex].src=imgCollapse.src;
}
else
{
ChangeRowVisibility(tableName,”collapse”, intRowIndex);
document.images[tableName+”.”+intRowIndex].src=imgExpand.src;
}
}

</script>
</body>
</html>
[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@slaughtersApr 10.2008 — Add a link that calls your initPanels function.
Copy linkTweet thisAlerts:
@bigaloauthorApr 11.2008 — Thanks, but that does not work correctly. Does anyone else have any solutionsor?
×

Success!

Help @bigalo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...