Solved

Accordian Table

Posted on 2011-03-16
3
383 Views
Last Modified: 2012-05-11
Can someon provide a code example that will alow me to have a bunch of rows.  When the row is clicked more rows with detail will how up underneath?

i.e.

row
   detail row
row
row
row

detail row(s) will show up under row when row is clicked.
0
Comment
Question by:kyleroi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
JF0 earned 500 total points
ID: 35150439
This should give you an idea.

<html>
<head>
<title></title>
<style>
.togBut {height:15px;width:15px;border: solid 1px #FFFFFF;}
.divAdd {border:solid 1px red;background-color:#e6e6fa;}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script>
<script>
	$(document).ready(function() {
		$('.divAdd').hide();
	
		$('.togBut').click(function(){
		
			$('.divAdd', $(this).parent().next()).slideToggle('normal');
		
		});
			
		$('.togBut').toggle(
			function(){
				$(this).children(":first").attr("src","minus.jpg");
				},
			function(){
				$(this).children(":first").attr("src","plus.jpg");
				}
		);
		
	});
</script>
</head>
<body>

<p/>

<table border='1'>
	<tr>
		<td>
			<div class='togBut'><img id='imgTog' src='plus.jpg' border='1' width='15' height='15' /></div>
		</td>
		<td>
			<div class="divAdd">xxxxxxxxxxx zzzzzzzzzzzzzzzzzzzzz<p/>aaaaa<p/></div>
		</td>
	</tr>					
	<tr>
		<td>
			<div class='togBut'><img id='imgTog' src='plus.jpg' border='1' width='15' height='15' /></div>
		</td>
		<td>
			<div class="divAdd">xxxxxxxxxxx zzzzzzzzzzzzzzzzzzzzz<p/>aaaaa<p/></div>
		</td>
	</tr>					
	<tr>
		<td>
			<div class='togBut'><img id='imgTog' src='plus.jpg' border='1' width='15' height='15' /></div>
		</td>
		<td>
			<div class="divAdd">xxxxxxxxxxx zzzzzzzzzzzzzzzzzzzzz<p/>aaaaa<p/></div>
		</td>
	</tr>					
</table>
</body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:kyleroi
ID: 35150524
this is adding columns to the right.  How do I add/show (sorry new at the terminology) rows below.  The idea being that you click an entire row (parent) with multiple columns and a new row is created(shown) beneath.
0
 
LVL 1

Author Comment

by:kyleroi
ID: 35150796
ok, using your code I came up with this, a bit dirty but I have the general Idea now

<html>
<head>
<title></title>
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script>
<script type="text/javascript">
	$(document).ready(function() {
		$('.child').hide();

		$('.parent').click(function(){
			$('.child').hide();
			$(this).nextUntil('.parent').fadeIn('normal');

		});

	});
</script>
</head>
<body>

<p/>

<table border='1'>
	<tr class="parent">
		<td>
			Parent
		</td>
	</tr>
	<tr class="child">
		<td>
			Child
		</td>
	<tr>
	<tr class="child">
			<td>
				Child
			</td>
	<tr>
	<tr class="parent">
			<td>
				Parent
			</td>
	</tr>
		<tr class="child">
			<td>
				Child
			</td>
		<tr>
		<tr class="child">
				<td>
					Child
				</td>
	<tr>
</table>
</body>
</html>

Open in new window

0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

636 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