Dynamic Content: click show and re-click disappear (IE) : Toggle « GUI Components « JavaScript DHTML

Home
JavaScript DHTML
1.Ajax Layer
2.Data Type
3.Date Time
4.Development
5.Document
6.Dojo toolkit
7.Event
8.Event onMethod
9.Ext JS
10.Form Control
11.GUI Components
12.HTML
13.Javascript Collections
14.Javascript Objects
15.Javascript Properties
16.jQuery
17.Language Basics
18.Mochkit
19.Mootools
20.Node Operation
21.Object Oriented
22.Page Components
23.Rico
24.Scriptaculous
25.Security
26.SmartClient
27.Style Layout
28.Table
29.Utilities
30.Window Browser
31.YUI Library
JavaScript DHTML » GUI Components » Toggle 
Dynamic Content: click show and re-click disappear (IE)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Dynamic Content</title>
<script language="javascript">
// Location of this script:
// http://www.qiksearch.com/javascripts/dynamic_content.htm
//*********************************************
//* Dynamic Content                           *
//* (c) Premshree Pillai,                     *
//* http://www.qiksearch.com                  *
//* E-mail : [email protected]            *
//* Use the script freely as long as this     *
//* message is intact                         *
//*********************************************
document.write('<form name="form1">');
document.write('<input type="hidden" name="cont1" value="ONE">');
document.write('<input type="hidden" name="cont2" value="TWO">');
document.write('<input type="hidden" name="cont3" value="THREE">');
document.write('</form>');
function showContent(name)
{
 val = name;
 if(document.all.prem.innerText!=eval('this.document.form1.' + val + '.value'))
 {
  document.all.prem.innerText =  eval('this.document.form1.' + val + '.value');
 }
 else
 {
  document.all.prem.innerText = "";
 }
}
</script>
<style type="text/css">
.link{font-family:verdana,arial,helvetica; font-size:10pt; color:#C00000; font-weight:bold; text-decoration:none}
.link:hover{font-family:verdana,arial,helvetica; font-size:10pt; color:#FA5D00; font-weight:bold; text-decoration:underline + overline}
.header{font-family:verdana,arial,helvetica; font-size:25pt; color:#000000; font-weight:bold; text-decoration:none}
.prem{font-family:verdana,arial,helvetica; font-size:10pt; color:#FF0000; font-weight:bold; text-decoration:none}
.premshree{font-family:verdana,arial,helvetica; font-size:8pt; color:#003399; font-weight:normal; text-decoration:underline}
.premshree:hover{font-family:verdana,arial,helvetica; font-size:8pt; color:#0099FF; font-weight:normal; text-decoration:underline}
</style>
</head>
<body bgcolor="#FFFFFF">
<center>
<span class="header">Dynamic Content</span>
<br><br>
<a href="javascript:showContent('cont1');" class="link">Content1</a> | <a href="javascript:showContent('cont2');" class="link">Content2</a> | <a href="javascript:showContent('cont3');" class="link">Content3</a>

<div id="prem" class="prem"></div>
</center>
<table align="center" width="400" cellspacing="5"><tr><td>
<font face="verdana,arial,helvetica" size="-1" color="#404040">
This JavaScript displays different content for different links. On clicking on the link the content becomes visible and on clicking
on it again it becomes hidden. 
<br><br>
Here only a single &lt;div&gt; tag has been used. The contents of each link is stored in the form of a hidden element.
</font>
</td></tr></table>
<br>
<center><a href="mailto:[email protected]class="premshree">&#169 Premshree Pillai</a></center>
</body>

</html>

           
       
Related examples in the same category
1.Toggle Multi select Widget
2.Toggle page
3.Create custom page and replace current document with it
4.Toggle web page
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.