Jump to content

Collapsable and Expandable Sections like facebook


don4g

Recommended Posts

Hey,

 

Im new to PHP and im tryin to figure out how to make those sections where you can minimize them or expand them like they have on facebook.com. I dont even know the correct term for it anythign would help. All info i find on the subject is for java but i have been working in php and im pretty sure facebook does it with php. any help would be greatly appreciated

 

thanks,

 

donny

Javascript:

 

<script language=javascript type='text/javascript'>
function hideDiv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow').style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.visibility = 'hidden';
}
else { // IE 4
document.all.hideshow.style.visibility = 'hidden';
}
}
}

function showDiv() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hideshow').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.hideshow.visibility = 'visible';
}
else { // IE 4
document.all.hideshow.style.visibility = 'visible';
}
}
}
</script>

As you can see it gets the div ID for each of the browsers and hides it or shows it. I named the Div Id hideshow to make it easy for you.

 

Then in your document put in your Div element the id name hideshow you can change this of course

 

<div id="hideshow" ..etc>
My content
</div>

 

and this to call the javascript to hide it

 

<a href="javascript:hideDiv()">hide Div</a>

 

and this to show it

 

<a href="javascript:showDiv()">show Div</a>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.