Solved

Exapand/collapse Div's in html

Posted on 2012-04-12
6
191 Views
Last Modified: 2012-04-13
Hi,
  How can I implement expand/collpase panels using div's. I don't want to install any active-x controls. I want to implement something like shown in the image. Please help me how can I do it.

Thank you
expand-collpase.png
0
Comment
Question by:Sthokala
6 Comments
 
LVL 6

Expert Comment

by:bartvd
ID: 37839572
Hide the div:

div.style.display = "none";

Expand the div:

div.style.display = "block";
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37839746
0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 37841261
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 7

Expert Comment

by:Atique Ansari
ID: 37841397
YOu can use jquery's slideToggle() function on div's click event.
0
 

Author Comment

by:Sthokala
ID: 37843034
Thank you for your answers. The code given is for horizontal panels..but I want the code to the two vertical panels. my question here is how can I insert an image in between two panels. please let me know.

Thank you
0
 
LVL 18

Accepted Solution

by:
nap0leon earned 500 total points
ID: 37843415
The panel layouts can be whatever you want.  In this example, they are named "left", "middle", and "right", but you can easily update the styles to make them "top", "middle", and "bottom" if you want...

All that is missing is that you place your image inside the div with id=middle (or set the image as middle's background) - whatever you prefer.

<script>
function toggleMiddle(){
	(document.getElementById('middle').style.display=='inline') ? document.getElementById('middle').style.display='none' : document.getElementById('middle').style.display='inline';
}
</script>
<style>
#left {border:1px solid black; height:300px; width:200px; float:left;}
#middle {border:1px solid black; height:300px; width:200px; float:left; display:none;}
#right {border:1px solid black; height:300px; width:200px; float:left;}
</style>
<div id="left">Left</div>
<div id="middle"></div>
<div id="right">Right</div>
<input type="button" onclick="toggleMiddle()">Toggle Middle DIV</input>

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question