Solved

Exapand/collapse Div's in html

Posted on 2012-04-12
6
190 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to init a part of Javascript based on PHP value for Datatables & Yadcf 8 49
Change div area and length 1 28
Button and js nou working 3 8
innerHTML 7 23
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.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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…

831 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