Solved

Accordian Table

Posted on 2011-03-16
3
376 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
  • 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now