View Full Version : {AJAX} - Open div close div
Eccentric
10-10-2007, 07:12 PM
Basically like the spolier:
example
for my comments thing...and full news.. :P :P
http://swindonsound.com/ss/shownews/
Assassinator
10-10-2007, 07:19 PM
Lmao:rolleyes:
<script language='JavaScript' type='text/javascript'>
<!--
function spoiler(obj)
{
for (var i = 0; i < obj.childNodes.length; i++)
{
if (obj.childNodes[i].id == 'idTitle')
titleRow = obj.childNodes[i];
if (obj.childNodes[i].id == 'idSpoiler')
{
if (obj.childNodes[i].style.display != 'none')
{
obj.childNodes[i].style.display = 'none';
titleRow.innerHTML = ' <b>Click to show spoiler</b>';
}
else
{
obj.childNodes[i].style.display = 'block';
titleRow.innerHTML = ' <b>Click to hide spoiler</b>';
}
}
}
}
//--></script>
<div width="100%" class="alt1" onclick="spoiler(this);" style="border-collapse: collapse; border: solid thin black;"><div id="idTitle" class="alt2" style="border-collapse: collapse; border: solid thin black; width: 100%;"> <b>Click to show spoiler</b></div><div id="idSpoiler" style="display: none;">example</div></div><br />
:eusa_whis
redtom
10-10-2007, 07:23 PM
Javascript file;
function simpletogglediv(whichLayer)
{
var theElementStyle = document.getElementById(whichLayer);
if(theElementStyle.style.display == "block")
{
theElementStyle.style.display = "none";
}
else
{
theElementStyle.style.display = "block";
}
}
Javascript Include;
<script type="text/javascript" src="filename.js"></script>
CSS Style Code;
#one, #two, #three {
display: none;
}
And more id's if you have more opening/closing divs on a page.
The link to open/close the div;
<a href="javascript:simpletogglediv('one');" title="link title"> Link name</a>
<a href="javascript:simpletogglediv('two');" title="link title"> Link name</a>
<a href="javascript:simpletogglediv('three');" title="link title"> Link name</a>
The divs;
<div id="one">
Content to open/close here.
</div>
<div id="two">
More Content to open/close here.
</div>
<div id="three">
Even more Content to open/close here.
</div>
Eccentric
10-10-2007, 07:27 PM
:P nice finding of the page source there kane, thanks tom ill try that later.
Assassinator
10-10-2007, 07:28 PM
:P nice finding of the page source there kane, thanks tom ill try that later.
Lol Source wth i wrote that.:eusa_whis
redtom
10-10-2007, 07:28 PM
:P nice finding of the page source there kane
Lol.
Tell me if you have any problems with it.
Eccentric
10-10-2007, 07:43 PM
Lol.
Tell me if you have any problems with it.
Thanks I will Tom<3
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.