FREE tutorial,solution,RSS Feeds on Operating Systems, Programming, Web Development, Applications, Databases, Networking, Hardware, Security, SEO Free Expertsforge Membership
Join us as Moderator
Submit Article to Expertsforge.com Submit Article My Expertsforge
 
RSS Feeds, Help Help RSS Feeds
bannertop
 

JavaScript Tutorial: Creating Expand/Collapse type of table in HTML and Javascript

jawahar
9/19/2007 5:19:35 AM, Views: 2240
The following tutorial and code can be used if you require an expand/collapse type of table in your web page.

You can copy and paste the code in an editor and save it as a html file and execute it.
Two images are used(+,-) to indicate if the table is in expanded state(-) or collapsed state(+). We dont have the image here, instead you can create one, or browse google to find one.

<html>
<head>
<script language="javascript">
var imgMax = new Image(10,10);
imgMax.src = 'images/max_arrow.gif';
var imgMin = new Image(10,10);
imgMin.src = 'images/min_arrow.gif';

function dyntog(a,thisimg)
{
   if(a.style.display=="none")
   {
      a.style.display="inline";
      thisimg.src=imgMax.src;
   }
   else if(a.style.display=="inline")
   {
      a.style.display="none";
      thisimg.src=imgMin.src;
   }
   return false;
}
</script>
<title>Expand/Collapse the table using DIV</title>
</head>
<body>
<img src="max_arrow.gif" width="10" height="10" border="0" align="absmiddle" style="cursor:hand" onclick="dyntog(tbltog_1,this)" title="Click to Minimize/Maximize the table">
<span id="tbltog_1" style="display:inline">First Line<BR>Second Line<BR></span>
</body>
</html>
Next Steps:
Add this Tutorial to:
Blink Blink del.icio.ous Del.icio.us Digg Digg
Fark Fark Furl Furl Google Google
Reddit Reddit Simpy Simpy Spurl Spurl
Technorati Technorati Windows Live Win Live Yahoo Yahoo
Rate Me!
Avg Visitor Rating: Average Visitor Rating is 4.5 out of 5
Number of Ratings : 4 Votes
Rate:
Send Private MessageSend Message
Signup / Login To View the Solution or Provide Comments
Post Comment/Solution
Comment:*
        (Link Rules) 
  Use : [bold] for <b>; [/bold] for </b>; [italic] for <i>; [/italic] for </i>; [code] & [/code] for code
 
Categories
Options
JavaScript RSS Feed
Most Popular Tutorial
Most Popular Solution
Top Rated
Top Rankers
Overall
1. jawahar (1400)
Yearly -2008
1. jawahar (200)
Expertsforge Sponsors
bnrtop